I\'ve developed a small write-only REST api with Flask Restful that accepts PUT request from a handful of clients that can potentially have changing IP addresses. My clients
You're right, OPTIONS
method called every time before real request in browser. OPTIONS
response have allowed methods and headers. Flask automatically process OPTIONS
requests.
To get access for cross domain request you API must have Access-Control-Allow-Origin
header. It can contain specific domains, but if you want allow requests from any domains you can set it to Access-Control-Allow-Origin: *
.
To set up CORS for flask
you can look at one extension code or try use this extension: https://github.com/wcdolphin/flask-cors/blob/master/flask_cors.py.
To set up CORS for flask-restful
look this pull requests: https://github.com/twilio/flask-restful/pull/122 and https://github.com/twilio/flask-restful/pull/131. But looks like flask-restful
does not support it by default yet.