On the backend I set the access token duration for 10 seconds and the refresh token is valid for 30 seconds and I set the refresh token as an httpOnly cookie.
The movies route is protected on the backend side and on the frontend side as well.
I set up a loader function for the movies route to get all the movies which are in the database.
When I go to the movies route when the access token is still valid, it loads the movies correctly and without any error. Although when I navigate away, for example to the home route, and want to come back to the movies route ONLY AFTER the access token expiration it does not load the movies and does not load the movies page either.
When the access token has expired and the refresh token is still valid I set up an axios interceptor to request a new access token and send again the request for the movies, but now with the new valid access token. When the refresh token is also invalid I redirect the user to the login page, so in order to see the content of the movies page, the user has to login again. After entering the credentials I setup the code to redirect the user to the requested route before the login page. Although this does not work and the ui is still on the login page.
When I implement this whole scenario without loaders and actions, ONLY WITH useEffect and custom use hooks, it works perfectly fine. The master branch contains this logic without loaders and actions. The required behavior can be seen there.
The router interceptor branch contains the logic with actions and loaders but required behavior does not work there.