index.js
app.use(cookieParser())
authToken.js
const jwt = require('jsonwebtoken');
async function authToken(req,res,next){
try {
const token = req.cookies?.token || req.header
console.log("token" , req.cookies.token ) **token and cookies appear as undefined**
/*
jwt.verify(token, process.env.TOKEN_SECRET_KEY, function(err, decoded) {
console.log(err)
console.log("decoded",decoded)
}); */
} catch (err) {
res.status(400).json({
message : err.message || err,
data : [],
error : true,
success : false
})
}
}
module.exports = authToken
console.log(“token” , req.cookies.token ) token and cookies appear as undefined
review => application => cookies
Although the token normally appears here, it does not appear on the console.
please can you help me about this problem
New contributor
MEHMET YILDIZ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.