You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my Nextjs application I'm getting REDIRECT error on my API ROUTE HANDLER
But first, what I want to do?
I would like to implement a custom sign-in flow that accepts only members of my team. For example, my team have four emails. Durging the sign-in process I need to verify if the current email is one of my team emails. If not, the current email does not have permissions to access my application.
My first question is: How would you do this? (give me some code example)
My code below
My Root layout have two children layouts:
AuthLayout (PUBLIC ROUTES)
AppLayout.(PRIVATE ROUTES)
In My app layout I verify if user is a member of team:
exportdefaultasyncfunctionAppLayout({ children }: Props){constuser: User|null=awaitcurrentUser()if(!user){redirect('/api/auth/sign-out')}// getting team emails this way for nowconstauthorizedEmails=env.ADMIN_MEMBERS.split(':')constuserEmail=user.emailAddresses[0].emailAddressif(!authorizedEmails.includes(userEmail)){redirect('/api/auth/sign-out')}return(<divclassName="grid grid-cols-app">{children}</div>)}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Nextjs 15 rc & React 19 rc
REPOSITORY
In my Nextjs application I'm getting REDIRECT error on my API ROUTE HANDLER
But first, what I want to do?
I would like to implement a custom sign-in flow that accepts only members of my team. For example, my team have four emails. Durging the sign-in process I need to verify if the current email is one of my team emails. If not, the current email does not have permissions to access my application.
My first question is: How would you do this? (give me some code example)
My code below
My Root layout have two children layouts:
AuthLayout (PUBLIC ROUTES)
AppLayout.(PRIVATE ROUTES)
In My app layout I verify if user is a member of team:
My api route handler
How can a fix the erros below?
Note there's a loop in my sign-out request


Beta Was this translation helpful? Give feedback.
All reactions