1. 20
    Hide Admin Routes from Non-Admin Users in a Remix App
    4m

Hide Admin Routes from Non-Admin Users in a Remix App

InstructorKent C. Dodds

Share this video with your friends

Send Tweet

Now that we have a conditional in for the admin button, we need to do the same for all of the admin routes because currently, they are still accessible to everyone.

We will set up a function to check if the user is an admin when accessing a route. If they are an admin, they will be able to proceed. If they are not, it will force a logout request which will redirect them.

Michael Sevestre
~ 2 years ago

Why do we need to await requireAdminUser(request); on all pages in the admin folder? (index and new). I assumed it would be enough to do it only in the admin.tsx file (and indeed, it seems to work). Am I missing something? Aren't the loader of the parent route called anyways?

Michael Sevestre
~ 2 years ago

oh well, I should have just listened until the end of the video. too eager once again.