Access-Control-Request-Method header is missing in CORS preflight request
But we don't want to make a preflight request in this case, just a CORS request using the OPTIONS method and Origin header.
Right now, the library is not allowing us to create our own implementation for OPTIONS and accessing it using scripts in browsers. In other words, the browser sends the preflight and receives 200 OK with the relevant headers, but the subsequent OPTIONS request (our implementation) fails with the error mentioned at the start.
A CORS request is an HTTP request that includes an Origin header.
Which applies to my example.
A CORS-preflight request is a CORS request [...] It uses OPTIONS as methodand includes the following header:
Access-Control-Request-Method
I interpret this part (emphasis mine) as a way to transform a CORS request into a preflight request. So, if it doesn't have the header it's just a no preflight CORS request (not an error).
After setting
corsIgnoreFailures = False
and doing a request like:The library returns:
But we don't want to make a preflight request in this case, just a CORS request using the
OPTIONS
method andOrigin
header.Right now, the library is not allowing us to create our own implementation for
OPTIONS
and accessing it using scripts in browsers. In other words, the browser sends the preflight and receives200 OK
with the relevant headers, but the subsequentOPTIONS
request (our implementation) fails with the error mentioned at the start.I used the spec as a source to support this https://fetch.spec.whatwg.org/#http-requests:
Which applies to my example.
I interpret this part (emphasis mine) as a way to transform a CORS request into a preflight request. So, if it doesn't have the header it's just a no preflight CORS request (not an error).