Replies: 2 comments
-
Because loaders run at the same time there's no way for them to know the refresh already happened, and the cookie with the session would be the old one any way. What I would do is to throw a redirect, to the same URL, after the refresh, so all loaders run again with the new refreshed user session. |
Beta Was this translation helpful? Give feedback.
-
The only time a navigation will result in a single request, is the initial document request. All subsequent navigations will make one or more requests in parallel to your loaders. Remix knows your routing structure, so when you navigate to a leaf with a common parent, then only the leaf loader is loaded. However, if you navigate to a non-common parent, then all loaders that match the new route will be called. Not to mention revalidation after action will cause all matching loaders to be called. Depending on your host (e.g. serverless), these requests may end up on different machines. So you really need to treat your loaders as independent endpoints. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Per how-can-i-have-a-parent-route-loader-validate-the-user-and-protect-all-child-routes I have a shared helper function that reads/validates the user permissions based on the session. This helper function has some logic that refreshes the user session as they continue to use the site.
However, due to the nature of the loaders, I might have 3-4 of them all attempting to refresh the session at once on every request.
Am I missing something? It seems wasteful to do this more than once-per-request.
Beta Was this translation helpful? Give feedback.
All reactions