【发布时间】:2018-07-06 09:06:37
【问题描述】:
我正在构建一个使用 API 与另一台服务器通信的反应应用程序。 API 调用正在使用axios,但在后端的护照身份验证上一直失败。 使用 Postman 进行身份验证,它与反应应用程序一起工作正常, res.isAuthenticaded 的值为 false。 这是使用邮递员到达服务器的值
[Node] req session--> Session {
[Node] cookie:
[Node] { path: '/',
[Node] _expires: null,
[Node] originalMaxAge: null,
[Node] httpOnly: true },
[Node] passport: { user: '5a6a04f017589a97237dc9df' },
[Node] returnTo: '/user/account' }
[Node] req session id--> a9uTD17j9fnPUYHd4srsfmvSfW6G3JZQ
[Node] isAuthenticated--> true
[Node] GET /user/account 200 210.616 ms - 54
这就是 react 应用的价值
Node] req session--> Session {
[Node] cookie:
[Node] { path: '/',
[Node] _expires: null,
[Node] originalMaxAge: null,
[Node] httpOnly: true },
[Node] returnTo: '/user/account' }
[Node] req session id--> 2cWySg06ZZuozdS4nklfnd-8H5iPYDsC
[Node] isAuthenticated--> false
[Node] GET /user/account 403 56.948 ms - 28
【问题讨论】:
-
您是否在使用会话存储?如果没有,它可能会解决您的问题
-
是的,我的请求确实具有
Cookie值,但似乎我发送服务器的方式不会处理它。附上我的 cookie 的打印件
标签: reactjs cookies react-redux passport.js axios