-
-
Save deangrant/6afbce5c9488ca9043dbc2fbb985e1fa to your computer and use it in GitHub Desktop.
Initializes cross origin resource sharing for the application in Flask-Cors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CORS_ORIGINS= | |
CORS_METHODS= | |
CORS_ALLOW_HEADERS= | |
CORS_EXPOSE_HEADERS= | |
CORS_SUPPORTS_CREDENTIALS= | |
CORS_MAX_AGE= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://flask-cors.corydolphin.com/en/latest/api.html | |
CORS( | |
app=app, | |
resources = app.config['CORS_RESOURCES'], | |
origins = app.config['CORS_ORIGINS'], | |
methods = app.config['CORS_METHODS'], | |
allow_headers = app.config['CORS_ALLOW_HEADERS'], | |
expose_headers = app.config['CORS_EXPOSE_HEADERS'], | |
supports_credentials = app.config['CORS_SUPPORTS_CREDENTIALS'], | |
max_age = app.config['CORS_MAX_AGE'] | |
) | |
@app.after_request | |
def after_request(response): | |
response.headers.add( | |
'Access-Control-Allow-Headers', app.config['CORS_ALLOW_HEADERS'] | |
) | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment