The POST method is automatically converted to OPTIONS

I mostly use the POST method, but it automatically converts to OPTIONS method. I know the browser does this but also reads that this is ok and should get a response like 201, but in my case it doesn't behave as expected, I also tried Access-Control-Allow-Methods in the request headers. but got nothing.

This is what my request looks like:

OPTIONS http://xyz/abc
Accept: application/json
Content-Type: application/json

      

Answer:

405, Method Not Allowed
Access-Control-Allow-Origin: *
Date: Tue, 05 May 2015 06:15:19 GMT
Connection: close
Accept-Ranges: bytes
Access-Control-Allow-Headers: authorization, content-type
Content-Length: 0
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, HEAD

      

Can anyone tell me the cause of this problem, and what the exact reason for this might be, after you have done enough research, everything looks good at my end. Thanks in advance.

+3


source to share


1 answer


You are probably seeing preflight check during POST request in resource sharing for different sources. I don't know how to configure your webserver to support this, but this Wikipedia article might be a first aid: http://en.wikipedia.org/wiki/Cross-origin_resource_sharing p>



The simplest solution is to make a POST request in the same origin where you load the web page. A reverse proxy might be a smart solution.

+2


source







All Articles