I need to perform a POST request using angular (http.post) and I need to pass my access credentials (I am using basic authentication) to my API (.NET) in my header.
Authorization : Basic dXNlcm5hbWU6cGFzc3dvcmQ =
No angular change the header as I need it
$http.defaults.headers.common.Authorization = 'Basic ' + credentials;
But when I do POST to the API, the Angle (or browser) changes my POST to OPTIONS
Request Method : OPTIONS
I have already looked in various places about it, but I could not find a solution. In the Web.Config of my API I have already set up to allow CORS.
<customHeaders>
<add name="Access-Control-Allow-Origin" value="http://localhost:9000" />
<add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept, Cache-Control" />
<add name="Access-Control-Allow-Credentials" value="true" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
Can anyone tell me what I might be doing wrong? How to look for the solution? Thanks in advance!