i am having an $http request in my localhost which is calling a url of some api. i am getting an error on executing the call
response for preflight has invalid http status code 403
can i do anything using angular so that i can fix this issue? i have cros plugin of chrome to allow cross origin request
$http({
method: 'post',
url: url,
data:data1,
headers: {
'access-control-allow-origin': '*',
}
})
ok so here's how i figured this out. it all has to do with cors policy. before the post request, chrome was doing a preflight options request, which should be handled and acknowledged by the server prior to the actual request. now this is really not what i wanted for such a simple server. hence, resetting the headers client side prevents the preflight:
the browser will now send a post directly. hope this helps a lot of folks out there... my real problem was not understanding cors enough.
link to a great explanation: http://www.html5rocks.com/en/tutorials/cors/
kudos to this answer for showing me the way. angularjs post fails: response for preflight has invalid http status code 404