类型错误:无法读取未定义的属性(读取"授权")



TypeError:无法读取未定义的属性(读取"authorization"(在verifyToken(file:///C:/Users/awan7/Downloads/JWT-AUTH/backend/medleware/VerifiedToken.js:4:35(

import jwt from "jsonwebtoken";
export const verifyToken = (res, req, next) => {
const authHeader = req.headers['authorization'];
const token = authHeader && authHeader.split(' ')[1];
if (token == null) return res.sendStatus(401);
jwt.verify(token, process.env.ACCESS_TOKEN_SECRET, (err, decoded) => {
if (err) return res.sendStatus(403);
req.email = decoded.email;
next();
})
}

我不知道什么是

import jwt from "jsonwebtoken";
export const verifyToken = (res, req, next) => { --->> i change my code from this
export const verifyToken = (req, res, next) => { <<---  in to this
const authHeader = req.headers['authorization'];
const token = authHeader && authHeader.split(' ')[1];
if (token == null) return res.sendStatus(401);
jwt.verify(token, process.env.ACCESS_TOKEN_SECRET, (err, decoded) => {
if (err) return res.sendStatus(403);
req.email = decoded.email;
next();
})
}

相关内容

  • 没有找到相关文章

最新更新