Freed0.0.7278766
I am building an authentication system using JWT in Node.js. I set the token expiry to 1 hour but users are getting logged out way before that.
I am generating the token like this:
const token = jwt.sign( { userId: user.id }, process.env.JWT_SECRET, { expiresIn: '1h' } );
And verifying it like this:
jwt.verify(token, process.env.JWT_SECRET, (err, decoded) => { if (err) { return res.status(401).json({ message: 'Token expired' }); } });
Users should stay logged in for 1 hour before the token expires.
Users are getting logged out after just a few minutes even though I set expiresIn to 1h.
No contributions yet. Be the first to answer!
Connect your wallet to post a contribution.