In this series of posts, we create a secured end-to-end JWT-based authentication mechanism using NodeJS, Express, PassportJS, and React. In this series I cover: Part 1: Background and Backend using NodeJS Part 2: React & JWT Authentication (This p...
blog.galmalachi.com18 min read
Assuming that the user has logged previously and that we have a valid refresh-token stored in a cookie, when we start the application again, user will be null until the token is refreshed.
Since user is null, any protected route will be redirected to login.
How do you usually wait for the first refresh to complete so the user is not redirected to login?
What happens when the token should be refreshed and you have multiple requests that are being sent at that time? Won't all the request get 401?
Jairo Pakes
Digital Solutions Director
Thanks, Gal. 4 years already and still great content. I'm a new to React and probably missing some basic knowledge, but what is the AuthEvents in your code?