我遇到问题了!!每次我尝试更新用户信息时,都会出现“无效令牌”错误,有人可以帮忙解决吗?
这是授权码
export const isAuth = (req, res, next) => {
const authorization = req.headers.authorization;
if (authorization) {
const token = authorization.slice(10, authorization.length);
jwt.verify(token, process.env.JWT_SECRET, (err, decode) => {
if (err) {
res.status(401).send({ message: 'Invalid Token' });
} else {
req.user = decode;
next();
}
});
} else {
res.status(401).send({ message: 'No Token' });
}
};