Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created November 10, 2020 21:35
Show Gist options
  • Save parzibyte/c3311007bd016556f679ad81a557344b to your computer and use it in GitHub Desktop.
Save parzibyte/c3311007bd016556f679ad81a557344b to your computer and use it in GitHub Desktop.
"""
Enable CORS. Disable it if you don't need CORS
"""
@app.after_request
def after_request(response):
response.headers["Access-Control-Allow-Origin"] = "*" # <- You can change "*" for a domain for example "http://localhost"
response.headers["Access-Control-Allow-Credentials"] = "true"
response.headers["Access-Control-Allow-Methods"] = "POST, GET, OPTIONS, PUT, DELETE"
response.headers["Access-Control-Allow-Headers"] = "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization"
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment