更新用户信息时出现无效令牌错误

问题描述 投票:0回答:0

我遇到问题了!!每次我尝试更新用户信息时,都会出现“无效令牌”错误,有人可以帮忙解决吗?

这是授权码

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' });

  }

};
node.js jwt bearer-token
© www.soinside.com 2019 - 2024. All rights reserved.