corydolphin / flask-cors

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

Configuring CORS for all Blueprints via Config #251

Open mfrlin opened 4 years ago

mfrlin commented 4 years ago

Is there any way to configure CORS for all Blueprints? If I set up CORS on the app and I register Blueprints then CORS won't work for those Blueprints. So now I have to configure CORS for each Blueprint separately. Furthermore I imagine (docs aren't clear about this) I can configure Flask app with a Config class with CORS_ORIGINS = [...] and it should work. But now CORS does not have access to the app and I have to do it like CORS(blueprint, origins=config_class.CORS_ORIGINS).

Is there a nicer way to do this?

JJJGGGG commented 5 months ago

For me, this worked for registered blueprints as app.register_blueprint(...) but if I registered them in a blueprint, i.e. as nested blueprints (blueprint.register_blueprint(...)) it didn't work. Maybe this is the issue