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
const isLoggedIn = await fetch(middlewareEndpoint('/auth/is-authenticated'), {
headers: headers(),
});
const hasVerifiedEmail = await fetch(middlewareEndpoint('/auth/is-verified'), {
headers: headers(),
});
// If user is logged in and trying to access a protected route, redirect them to the email verification page
if (protectedSignupRoutes.includes(request.nextUrl.pathname) && isLoggedIn.status === 200) {
if (hasVerifiedEmail.status !== 200) {
return NextResponse.redirect(new URL('/signup/email-verification', request.url));
}
}
// If user is logged in, pass them to their page
if (isLoggedIn.status === 200) {
return NextResponse.next();
}
Trying to do something like this but you can't just wrap the NextResponse.redirect(new URL('/signup/email-verification', request.url)); in the I18nMiddleware function
I see that in v2 branch it looks like they are making support for that but there hasn't been anything since march
I'm really liking the library, quite simple to set up, but I'm having a little trouble doing validations and redirects if necessary in the middleware.
I appreciate if someone can send some example code, how a validation should be done and if necessary redirect through the middleware.ts.
The text was updated successfully, but these errors were encountered: