I am building an api with flask-restful and an ionic/angular mobile app, but requests to the api are failing with the error "XMLHttpRequest cannot load http://localhost:5000/api/v1/auth. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access. The response had HTTP status code 400." even after specifying the Access-Control-Allow-Origin header in the Resource response.
class Auth(Resource):
def post(self):
#some code here
return responseObject,200,{'Access-Control-Allow-Origin':'*'}
I have tried different browsers and when i check the network XHR calls the response headers don't show the it.
Content-Length:90 Content-Type:application/json Date:Thu, 14 Sep 2017 11:46:25 GMT Server:Werkzeug/0.12.2 Python/2.7.10
Yet when i use postman to send the requests, i see the Access-Control-Allow-Origin header
acccess-control-allow-origin →* content-length →198 content-type →application/json date →Thu, 14 Sep 2017 12:54:52 GMT server →Werkzeug/0.12.2 Python/2.7.10
Anyone with an idea of what is happening, i will be glad to receive your help.
thanks in advance.
I think that you have to allow cross origin calls in your API. Have a look here : http://flask-cors.readthedocs.io/en/latest/