[英]Why does Fetch API Send the first PUT request as OPTIONS
I am trying to make a cors
PUT request using the vanilla Fetch API 我正在尝试使用
cors
Fetch API发出cors
PUT请求
When I click my button to send the PUT request, the method on the first request is OPTIONS
. 当我单击按钮发送PUT请求时,第一个请求的方法是
OPTIONS
。 It is only when I click the button again, then the method on the request changes to PUT
. 只有当我再次单击该按钮时,请求中的方法才变为
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? 我了解这是CORS预检的一部分,但是有没有办法手动触发预检,以便可以缓存OPTIONS响应?
Could this behavior be indicative of a failing promise somewhere? 这种行为是否可以表明某个地方的诺言失败?
See the Fetch Standard , section 4.7. 请参阅提取标准第4.7节。 CORS-preflight fetch .
CORS-preflight提取 。
Note : This is effectively the user agent implementation of the check to see if the CORS protocol is understood.
注意 :这是检查是否理解CORS协议的有效用户代理实现。 The so-called CORS-preflight request .
所谓的CORS-preflight request 。 If successful it populates the CORS-preflight cache to minimize the number of these fetches.
如果成功,它将填充CORS-preflight缓存,以最大程度地减少这些提取的次数。
at steps 1 through 7; 在步骤1到7; also 4.8.
也是4.8。 CORS-preflight cache .
CORS预检缓存 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.