I would like to make check-auth but return to me
JsonWebTokenError: secret or public key must be provided
I can take token successful
how can i fix this?
I am following this tutorial ;
https://www.youtube.com/watch?v=8Ip0pcwbWYM&t=633s
const jwt = require('jsonwebtoken');
module.exports = (req, res, next) => {
try {
const token = req.headers.authorization.split(" ")[1];
console.log(token);
const decoded = jwt.verify(token, process.env.JWT_KEY);
req.userData = decoded;
next();
} catch (error) {
console.log(error);
return res.status(401).json({
message: 'Auth failed'
})
}
}