Flask-CORS not working for POST, but working for GET Flask-CORS not working for POST, but working for GET python python

Flask-CORS not working for POST, but working for GET


You have to add CORS(app, resources={r"/*": {"origins": "*"}}) into your flask app.

Hope that solves the issue.


In my case, a CORS error raised because of an internal error. An error completely unrelated to CORS, which should return 500, was causing this.


the Flask-Cors docs explain why this might happen

"When using JSON cross origin, browsers will issue a pre-flight OPTIONS request for POST requests. In order for browsers to allow POST requests with a JSON content type, you must allow the Content-Type header. The simplest way to do this is to simply set the CORS_HEADERS configuration value on your application: e.g."

https://flask-cors.readthedocs.io/en/1.9.0/

app.config['CORS_HEADERS'] = 'Content-Type'