I searched many article for days i find they sending the token like this
res.json({token})
and using a middleware like this
function verifyToken(req, res, next){
const authHeader = req.headers['authorization']
const token = authHeader && authHeader.split(' ')[1]
if (token == null) return res.sendStatus(401); // No token provided
if(jwt.verify(token,process.env.JWT_SECRET)){
next()
}
}
How do they put that token in the req.headers['authorization']
when i console.log
that it gives me only undefined
the res.json({token})
only send me to the token