We have the following setup :
Front end code : REACT (Hosted using express js) (lets call this www.domainA.com)
Backend : .NET WEB API (Hosted in IIS 7.5) (lets call this www.domainB.com)
The domain of the FE app is making the request to GET data and POST data to the web api.
The GET is working perfectly, however whenever I am trying to POST data to the web API, its throwing the following error :
Request URL: http://www.domainB.com/api/postdataoperation
Request Method: OPTIONS
Status Code: 403 Forbidden
I have looked at many CORS articles and went ahead and setup HTTPResponseHeaders in IIS as follows :
Access-Control-Allow-Methods : POST,GET,OPTIONS,PUT,DELETE
Access-Control-Allow-Origin : http://www.domainA.com
The post request from react solution is as follows :
axios.post(`http://www.domainB.com/api/postdataoperation`, {userId});