I'm confused about that my API server (NodeJS Express) only allow GET method
res.setHeader('Access-Control-Allow-Methods', 'GET');
then I make a CORS POST request with header
headers: {
'Content-Type': 'application/json',
'X-Test-Header': 'TESTING'
}
(the purpose is force browser to call OPTIONS request before a POST request). Then I inspect Network Tab in Chrome Debug, it does send 2 request (first with OPTIONS then POST request). The response header of OPTIONS request is:
Access-Control-Allow-Methods: GET
the question is why it still calls POST request when POST verb is not included in Allow-Methods headers?
Anyone know this please explain to me. Thanks in advance.
P/S: With DELETE or PUT method, it will throw an error
has been blocked by CORS policy: Method PUT is not allowed
by Access-Control-Allow-Methods in preflight response.
I think with POST method it must throw the same error to indicate the method is not allowed
P/S: I'm still facing about this issue, Does anyone know it and explain to me, thanks in advance