I am trying to make a cors PUT request using the vanilla Fetch API
When I click my button to send the PUT request, the method on the first request is OPTIONS. It is only when I click the button again, then the method on the request changes to PUT. Why?
I understand this is part of the CORS preflight, but is there a way to trigger the preflight manually so the OPTIONS response can be cached?
Could this behavior be indicative of a failing promise somewhere?
See the Fetch Standard, section 4.7. CORS-preflight fetch.
Note: This is effectively the user agent implementation of the check to see if the CORS protocol is understood. The so-called CORS-preflight request. If successful it populates the CORS-preflight cache to minimize the number of these fetches.
at steps 1 through 7; also 4.8. CORS-preflight cache.
来源:https://stackoverflow.com/questions/42311018/why-does-fetch-api-send-the-first-put-request-as-options