corydolphin / flask-cors

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

Preflight requests must return OK #297

Open CrafterSvK opened 3 years ago

CrafterSvK commented 3 years ago

Hello, I found out that every OPTIONS request from origin must provide response with response code 200. Without the response code, it will get ignored and preflight request fails. Should we implement this or make it more visible? (Solution is to create before_app_request and checking the OPTIONS method in your flask application). But if preflight should fail due to Access-Control-Allow-Origin not being the same as origin needs, what should we return?

tobiaslocker commented 2 years ago

I found this behavior also irritating, forces me to add the following logic when I e.g. want to return 201 for a POST request

    if request.method == 'OPTIONS':
        return make_response('OK', 200)

This seems redundant and I guess it could be handled in flask-cors