【问题标题】:Unable to read cookie sent from React js frontend on Express server无法读取从 Express 服务器上的 React js 前端发送的 cookie
【发布时间】:2020-11-06 16:51:10
【问题描述】:

在我的 React js 前端,我设置了一个带有 react-cookie 的 cookie。 我已验证请求 cookie 设置正确:

在 Express 服务器上,我设置了cookie parser

app.use(cookieParser())

app.get('/instruments', function (req, res) {
  // Cookies that have not been signed
  console.log('Cookies: ', req.cookies)

  // Cookies that have been signed
  console.log('Signed Cookies: ', req.signedCookies)
})

正如我们所见,cookie 在服务器上是不可见的。为什么会这样?

【问题讨论】:

  • 检查你的 React 部分。

标签: javascript node.js reactjs typescript express


【解决方案1】:

您的代码运行正常

access-token=%7B%7D url 解码为access-token={}

您的终端中记录的内容是什么

看来您使用react-cookie 发送cookie 值部分是问题而不是传输或服务器

【讨论】:

    猜你喜欢
    • 2016-05-29
    • 1970-01-01
    • 2019-08-14
    • 2020-12-29
    • 2020-11-26
    • 2017-10-18
    • 1970-01-01
    • 1970-01-01
    • 2017-04-15
    相关资源
    最近更新 更多