Next.js Discord

Discord Forum

How to manage public, protected, and user-role routes?

Unanswered
Barbary Lion posted this in #help-forum
Open in Discord
Avatar
Barbary LionOP
I have a next.js application with a mix of auth and public pages.
The middleware is setup to look at hardcoded arrays (publicRoutes, protectedRoutes, adminRoutes) and I'm just wondering if there is a better approach?

When a new page is added, I'll need to manually add the route to one of these arrays.
Also, I'm using playwright, amongst other things, to run a smoke test on all of these routes.

It seems like there is a lot of room for user error and for things to, "fall between the cracks"
Maybe someone has encountered this issue and has some tips?

All suggestions/info is

0 Replies