【发布时间】:2020-11-04 19:59:39
【问题描述】:
所以我目前正在使用 nodejs、express、mongodb、jwt 和 hbs 构建一个 todo 应用程序。我让一切都在本地工作,但是当我最终将我的站点部署到 heroku 时,我要么得到一个无法识别的令牌,要么得到一个内部服务器错误(错误代码 500),换句话说,一个“JWT 无效令牌错误”。那么为什么它在部署时不工作,但在本地工作?我该如何解决它。
使用此标记时,令牌返回未定义
const authHeader = req.headers["cookie"].split(" ")[1]
console.log(authHeader)
if(authHeader !== undefined) {
token = authHeader.substring(6)
console.log(token)
}
但是没有那个,并且只是使用这个,我得到了整个令牌,但是一个 JWT 无效令牌错误。
const authHeader = req.headers["cookie"]
console.log(authHeader)
if(authHeader !== undefined) {
token = authHeader.substring(6)
console.log(token)
}
【问题讨论】:
标签: node.js express heroku jwt authorization