Express控制器未返回cookie

Express控制器未返回cookie,express,cookies,jwt,Express,Cookies,Jwt,此代码段是处理用户登录的快速路由的一部分。一切都很顺利,但始终没有回复。return语句之前的console.log返回一个令牌,因此我知道jwt正确地对令牌进行了签名,而在这之前的所有操作都正常工作。但是在控制台和return语句之间,响应只是挂起,函数超时。知道为什么会这样吗 User.findOne({ email }, { _id: 1, name: 1 }) .then(user => { jwt.sign({ _id: user.

此代码段是处理用户登录的快速路由的一部分。一切都很顺利,但始终没有回复。return语句之前的console.log返回一个令牌,因此我知道jwt正确地对令牌进行了签名,而在这之前的所有操作都正常工作。但是在控制台和return语句之间,响应只是挂起,函数超时。知道为什么会这样吗

User.findOne({ email }, { _id: 1, name: 1 })
    .then(user => {
        jwt.sign({
            _id: user._id,
            name: user.name
        }, authSecret, { expiresIn: "3d" }, (err, token) => {
            if(err) return res.status(500).json({ message: err.message });

            console.log(`Token signed: ${token}`);

            return res.status(201).cookie("accessToken", token, {
                httpOnly: true,
                maxAge: 3*24*60*60*1000,
                signed: true,
                secure: true
            });
        });
    })
.status和.cookie只需准备要发送的响应。你需要打电话或至少实际发送回复