Friday 12 January 2018

[Express] How to redirect user when his session is expired?

So far, I've tried to redirect the user when his JWT is expired via res.redirect(403, '/logout') with middleware, but nothing happens. I have a console.log right before that, and it definitely realizes the users token is expired, but the redirect does nothing. I didn't find a lot via google, but I think it has to do with my backend and frontend being split.How do you solve this issue? When the user's token is expired, I want him to get 'logged out' and told to re-login, not to continue to browse the page with plenty of errors.Thanks! :) Help and resources to read are welcome (or showing/telling me how you've handled this issue)!

Submitted January 12, 2018 at 08:17AM by zonq

No comments:

Post a Comment