【发布时间】:2020-01-24 04:16:20
【问题描述】:
我正在使用站点 https://a.com 进行身份验证。验证后,我访问http://b.com。当我从 b.com 向 a.com 发出 get 请求时,a.com 为我需要发送的会话设置了一个 cookie。
您能否告诉我,我如何获取 cookie 并将其与我的请求一起传递。
我尝试使用“withCredentials”发送请求:true, 还尝试将 axios-cookiejar-support 与 strong-cookie 一起使用。但是好像没用。
.get(a.com/path-requiring-cookie, {
withCredentials: true,
headers: {
'Content-Type': 'application/json',
'access-control-allow-credentials': true,
},
})
.then(res => {
console.log(res.data);
});```
This is the code that I have to send the request.
But this doesn't seem to send the cookie with the request. Can someone please clarify.
【问题讨论】:
标签: javascript cookies axios