gpt4 book ai didi

javascript - Fetch 未从 302 重定向调用中检索响应

转载 作者:行者123 更新时间:2023-12-05 02:14:01 24 4
gpt4 key购买 nike

<分区>

在 ReactJS 组件中,对重定向到另一个 API 的 API 的提取调用不会返回最终目的地的响应。 Fetch 只是返回带有 null 0 等的 opaque 响应,就像您的调用失败一样。它甚至没有说它重定向了。但是在 Chrome 的控制台中,Network 选项卡清楚地显示重定向调用成功。

            let call = fetch(encodedQueryUrl, {
method: 'GET',
cache: 'no-cache',
mode: 'no-cors',
redirect: 'follow',
credentials: 'same-origin'
}).then((response) => {
console.log("Response???", response);
return response;
});

所以 encodedQueryURL 响应头:

Request Method: GET
Status Code: 302
Referrer Policy: no-referrer-when-downgrade
Access-Control-Allow-Headers: access-control-allow-origin
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE
Access-Control-Allow-Origin: *
content-length: 0
content-type: text/html; charset=UTF-8

以及 302 响应 header :

Request Method: GET
Status Code: 200
Referrer Policy: no-referrer-when-downgrade
Access-Control-Allow-Headers: access-control-allow-origin
access-control-allow-methods: GET, POST, GET, OPTIONS, PUT, DELETE
access-control-allow-origin: *
content-type: application/json; charset=UTF-8

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com