Request not responding, Why an OPTIONS method is sent before my request ?
See original GitHub issueI’ve been having a problem i don’t really have using jQuery Ajax methods, when i use axios, my request sends one Request Method:OPTIONS
in it’s header and doesn’t respond (neither GET nor POST request).
With jQuery the same endpoint works fine, but with axios it keeps telling me :
Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.
though i didn’t sent any Access-Control-Allow-Headers
with my request.
I even tried :
axios.defaults.headers.common['Access-Control-Request-Headers'] = null
axios.defaults.headers.common['Access-Control-Request-Method'] = null
any ideas ? bug ? normal ?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:17
- Comments:21 (1 by maintainers)
Top Results From Across the Web
Why is an OPTIONS request sent and can I disable it?
According to the CORS strategy (highly recommend you read about it) You can't just force the browser to stop sending OPTIONS request if...
Read more >Why is my browser sending an OPTIONS HTTP request ...
A preflight request, is a mechanism in CORS by the browser to check if the resource destination is willing to accept the real...
Read more >OPTIONS - HTTP - MDN Web Docs
In CORS, a preflight request is sent with the OPTIONS method so that the server can respond if it is acceptable to send...
Read more >Why Is an OPTIONS Request Sent? - Baeldung
The OPTIONS request mentioned in the introduction is a preflight request, which is part of the CORS (Cross-Origin Resource Sharing).
Read more >RFC 7231: Hypertext Transfer Protocol (HTTP/1.1)
In order to improve the server's guess, a user agent MAY send request ... the origin server SHOULD respond with the 405 (Method...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
axios uses the
application/json
format by default, while jQuery usesapplication/x-www-form-urlencoded
. Cross site requests in the former format are always preflighted, while cross site requests in the latter format may be not preflighted. Please see this for details.Hope this helps!
Have a look at CORS and more specifically to the pre-flighted requests.
Basically the
OPTIONS
request is used to check if you are allowed to perform theGET
request from that domain and what headers can be used for that request. This is not axios specific.