Description:
This repository shares the code applied during the Node Server.
- When logging in, you get access token
- When you go to the router
/admin, it will start and fetch data from a mock users from the back-end of MongoDB server - When you get a network call that is
xhr.js:210 GET http://localhost:3500/employees 403 (Forbidden), that means React will use axios and try to intercept the response from the error, and try to send a new refresh token to the Node.js back-end server end pointauth/refreshto validate to check if you still have authorization from the client side - If you are still authorized, you are still on the page
/adminpage - If you are not authorized, it will redirect you back to the
/loginpage
There is a file tokenExpiration.js. from the repo of the Node.js server. Here, you can try to modify the expiration date for the access token and refresh tokens.
- The access token is set as expiration time 1 day
- The refresh token is set as expiration time for 30 seconds
The refresh token is where we get the network call that we will get 403 (forbidden) after 30 seconds from the /employees router path