Next.js Discord

Discord Forum

Redirect unverified roles on all routes to /welcome

Unanswered
Southern rough shrimp posted this in #help-forum
Open in Discord
Southern rough shrimpOP
Hi, I want redirect every user with unverified role to '/welcome' route. I want them to not be able to visit any other route.
I've tried middleware and it caused 'too many redirects' error. also tried to implmenet it in the RootLayout but I couldn't get the url pathname to see if the user is already in '/welcome'

Can somebody help please?

1 Reply

Abyssinian
Hi Uberzeek, using middleware for redirection does seem to be the best solution for you. Your error could have many potential causes. May we take a look at your middleware.ts?