flask-cors
flask-cors copied to clipboard
from origin 'https://xxx.com' has been blocked by CORS policy
Hi, I recently encountered an occasional problem. Could you help me look at this problem? Thank you very much.
from origin 'https://xxx.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource
from flask_cors import CORS
CORS(app, resources=[r'/survey/platform/*', r'/athena/survey/platform/*'], supports_credentials=True)
This error is sometimes caused by uncaught exceptions in your program.
Try this:
CORS(app, resources={r'/athena/*': {origins: '*'}})
In my case the cors configuration was correct. I had to change the PROPAGATE_EXCEPTIONS
attribute to false in the app settings.
app = Flask(__name__)
app.config['PROPAGATE_EXCEPTIONS'] = False
PROPAGATE_EXCEPTIONS Exceptions are re-raised rather than being handled by the app’s error handlers. If not set, this is implicitly true if TESTING or DEBUG is enabled. Default: None
@corydolphin I recommend closing this issue due to its age.