Here is a screenshot showing the error message:
This is the code for the client-side:
API with attached jwt:
Take a look at the function used to verify the jwt:
const authHeader = req.headers?.authorization;
if(!authHeader){
return res.status(401).send({message: 'Unauthorized access'})
}
const token = authHeader.split(' ')[1];
jwt.verify(token, process.env.SECRET_TOKEN, (err, decoded)=>{
if(err){
return res.status(403).send({message: 'Forbidden access'})
}
console.log('decoded', decoded);
req.decoded = decoded;
})
next();
}