提问人:santhazh 提问时间:6/6/2023 最后编辑:santhazh 更新时间:6/6/2023 访问量:291
重定向:fetch 中的“manual”重定向到请求 URL,而不是重定向到响应中的标头位置
redirect: "manual" in fetch redirects to the request URL instead of redirecting to header location in response
问:
我有以下代码用于获取响应标头位置。
let callAuthorize = async() => {
try {
const authorizeResponse = await fetch(requesturl,
{redirect: "manual", mode:'cors',
headers: {
"Cache-Control": "no-store",
"Accept-Charset": "UTF-8",
"Access-Control-Expose-Headers": "location"
}
});
if (authorizeResponse.type === "opaqueredirect") {
window.location.href = authorizeResponse.url;
}
}
catch (e) {
console.log(e)
}
但它重定向到 requestURL,而不是重定向到标头位置作为响应。
由于 CORS 问题,正常的 fetch 调用无法获取响应标头。
答: 暂无答案
评论