corydolphin / flask-cors

Cross Origin Resource Sharing ( CORS ) support for Flask
https://flask-cors.corydolphin.com/
MIT License
873 stars 140 forks source link

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

Open nanfangstation opened 3 years ago

nanfangstation commented 3 years ago

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

nejat-njonjo commented 3 years ago

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

Try this:

CORS(app, resources={r'/athena/*': {origins: '*'}})
bacarPereira commented 2 years ago

In my case the cors configuration was correct. I had to change thePROPAGATE_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

kurtmckee commented 3 months ago

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