如何将 withCredentials 选项传递给请求?
How to pass withCredentials option to Request?
根据 CORS spec,可以在 XHR 或 Fetch 请求上设置 withCredentials: true
以在飞行前请求中包含授权凭据。
我正在使用请求库(在浏览器中)。我怎样才能让 属性 通过?简单地在选项中包含 { withCredentials
} 似乎不起作用:
request.get({
...,
auth: {...},
withCredentials: true
})
为了回答我自己的问题,我已经确认 Request
库确实支持 withCredentials: true
选项(或者更确切地说,它的一个依赖项支持),并且它最终被翻译成credentials: "include"
参数传递给 fetch()
.
如上面评论所述,that 的行为不是我所期望的,但问题不在于 Request。
根据 CORS spec,可以在 XHR 或 Fetch 请求上设置 withCredentials: true
以在飞行前请求中包含授权凭据。
我正在使用请求库(在浏览器中)。我怎样才能让 属性 通过?简单地在选项中包含 { withCredentials
} 似乎不起作用:
request.get({
...,
auth: {...},
withCredentials: true
})
为了回答我自己的问题,我已经确认 Request
库确实支持 withCredentials: true
选项(或者更确切地说,它的一个依赖项支持),并且它最终被翻译成credentials: "include"
参数传递给 fetch()
.
如上面评论所述,that 的行为不是我所期望的,但问题不在于 Request。