nour nour nour nour - 4 months ago 9
AngularJS Question

Having OPTIONS method instead of POST

I want to post input values in my webservice. I had many errors when I checked, I found that OPTIONS was used not POST

enter image description here

Here's my code:

var req = {
headers: {

It's strange why I had OPTIONS not POST and how can I solve such problem? (I am using AngularJS)


From the access-control-request-method header, you're looking at a CORS preflight request. These happen when you're going across origins, before the actual request is sent. The server may respond with headers to indicate whether the actual request is allowed or not, based on source origin, method, etc.

From the MDN docs, any POST request sending JSON will have a corresponding preflight request:

In particular, a request is preflighted if:

  • It uses methods other than GET, HEAD or POST. Also, if POST is used to send request data with a Content-Type other than application/x-www-form-urlencoded, multipart/form-data, or text/plain, e.g. if the POST request sends an XML payload to the server using application/xml or text/xml, then the request is preflighted.