0
I have a function to protect the route. Use as follows
const authMiddleware = async (req, res, next) => {
const token = req.header('Authorization')?.replace('Bearer ', '')
if(!token) return anauthorized(res)
jwt.verify(token, JWT_SECRET, (err, decoded) => {
if(err) {
console.log(err)
}
console.log(decoded)
next();
})
}
I can get everything right. jwt.Verify gives me an error
JsonWebTokenError: invalid algorithm
I have tried to implement several solutions, but without success. What I could do?
The JWT has, in the header, a definition of the algorithm that was used when signing. You probably created the token with an algorithm that is not supported by the function
verify
you are using. How you are creating the token?– Luiz Felipe
This token comes from the login with google, who generates it. I just send the same in the header of fetch.
– Deise