How would you enable Cross-Origin Resource Sharing (CORS) in a Flask application?

  • Add Access-Control-Allow-Origin header to each route manually.
  • CORS is not applicable to Flask applications.
  • Set CORS_ENABLED = True in the Flask app configuration.
  • Use the @cross_origin decorator from the flask_cors extension.
To enable CORS in a Flask application, you typically use the @cross_origin decorator provided by the flask_cors extension. This allows you to control which origins are allowed to access your API.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *