Skip to content

Protected sub routes #178

Answered by sergiodxa
binajmen asked this question in Q&A
Jul 8, 2022 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

Every loader/action function should verify if the user is authenticated, there's no way to protect sub routes in Remix because Remix may or may not call the parent loader.

Let's say you have routes/protected.tsx and routes/protected/child1.tsx and routes/protected/child2.tsx and you only call authenticator.isAuthenticated in the routes/protected.tsx file.

When the user goes to /protected/child1 because it was a document request Remix will call all loaders and if the user is not authenticated it will be redirected.

Now suppose the user clicks a Link to /protected/child2, because Remix already have the data of routes/protected.tsx it will not fetch that loader again, and it will only fetch …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@binajmen
Comment options

@mcgaw
Comment options

@binajmen
Comment options

@mcgaw
Comment options

Answer selected by sergiodxa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants