我正在尝试在 Axios 请求中设置 cookie,以便将其发送到我的 Django 后端。问题是没有发送cookie,根据我的后端,请求中没有cookie。
这是我尝试过的:
return axios({
method: 'post',
url: 'http://127.0.0.1:8000/testreq',
withCredentials: true,
credentials: "include",
headers: {'test-cookie': '1234'}
}).then(function (response) {
console.log(response)
}).catch(function (error) {
console.log(error)
});
如果我打开 Chrome devtools 选项卡,test-cookie
不在标题的 Cookie
字段中,如果我尝试打印我发送的请求中的 cookie,它只是空的。如何设置 cookie 并从 Axios 发送?我已经确保在我的后端禁用安全设置