当我在 Postman 中执行注册操作时,控制台中出现以下错误:错误:TypeError: 回调不是函数,node_modules\jsonwebtoken\sign.js:101:14)问题出在这一行:const token = jwt.sign({name, email, password}, process.env.JWT_SECRET, process.env.JWT_ACCOUNT_ACTIVATION, {expiresIn: '10m'});控制器/认证const User = require('../models/user');const jwt = require('jsonwebtoken');exports.signup = (req, res) => { const {name, email, password} = req.body; User.findOne({email}).exec((err, user) => { if (user) { return res.status(400).json({ error: "Email is taken" }) } const token = jwt.sign({name, email, password}, process.env.JWT_SECRET, process.env.JWT_ACCOUNT_ACTIVATION, {expiresIn: '10m'}); });};更新当我删除process.env.JWT_SECRET时,它可以工作。我必须使用process.env.JWT_SECRET吗?
添加回答
举报
0/150
提交
取消