I have an angular 8 application which makes a POST request to Flask REST API's which are hosted on IIS server(with windows Authntication). The problem is every time I do a POST request from my angular code I get CORS error:
Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
The api's work fine when I call them directly from browser directly the problem is when I call them from my angular project.
I have used the flask-CORS library:
cors = CORS(app, resources={r"/*": {"origins": "*"}})
@app.route('/', methods=['GET', 'POST'])
@cross_origin(origin='*', headers=['Content-Type', 'Authorization'], supports_credentials=True)
def home():
"""
Returns template for Home page .
"""
return "<h1>Home Page</h1>"
I In my IIS server I have set these HTTP response headers:
Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS
When I check the network tab I get CORS error and not status 401 so I assume the error is not an authentication issue.
I have been through multiple stackoverflow questions but all of them deal with ASP.net and the few that deal with flask they all mentioned setting the Headers in IIS server but my issue remains unsolved.
Please guide me on this...
EDIT
This are my response headers:
Provisional headers are shown
Accept: application/json, text/plain, */*
content-type: application/json