flask-cors icon indicating copy to clipboard operation
flask-cors copied to clipboard

from origin 'https://xxx.com' has been blocked by CORS policy

Open nanfangstation opened this issue 3 years ago • 3 comments

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)

image

nanfangstation avatar Nov 04 '20 09:11 nanfangstation

This error is sometimes caused by uncaught exceptions in your program.

Try this:

CORS(app, resources={r'/athena/*': {origins: '*'}})

nejat-njonjo avatar Feb 22 '21 16:02 nejat-njonjo

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

bacarPereira avatar Jun 13 '22 21:06 bacarPereira

@corydolphin I recommend closing this issue due to its age.

kurtmckee avatar Mar 26 '24 12:03 kurtmckee