Page redirect not working return res.redirect('/logout');
Current url http://localhost:3000/abc/cccccc - Re-direction to http://localhost:3000/logout
exports.tokenVeryAndNext = async (req, res, next) => {
let token = req.cookies.token;
if(token == null || token == "undefined") {
return res.redirect('/logout');
}
try{
let decoded = jwt.verify(token, config.JWT_KEY_2);
let userDoc = await User.findById(decoded.id);
console.log(userDoc)
req.user = userDoc;
next();
});
}catch(err){
console.log(err.name, "jwt error");
return res.redirect('/logout');
}
}