HttpOnly cookie 未保存在浏览器中

时间:2021-04-09 11:54:04

标签: reactjs cookies next.js strapi httponly

我的 HttpOnly cookie 有问题,我有一个自定义身份验证 API,它在我登录时返回一个带有令牌的 HttpOnly cookie,但问题是,当我使用 withCredentials 在 Axios 前面发出另一个请求时,cookie 是不发送标题,我不明白为什么。

我使用 NextJs 作为前端,使用 Strapi 作为后端

这是对 API 的请求,它返回 cookie Here is the request to the API, which returns me the cookie

这是我刚刚做的一个请求 And here is a request that i do just after

这是创建第二个请求的代码

await axios.get(param.endpoints.getMe, {withCredentials: true})

1 个答案:

答案 0 :(得分:0)

解决方案

问题是我忘记在登录请求中添加“withCredentials: true”。

我在这上面花了 4 个小时。

我讨厌自己