fix(admin): break redirect loop on /forbidden for non-admin users
The middleware was redirecting non-admins to /forbidden but /forbidden wasn't excluded from the matcher, so the middleware ran again on that page, saw a non-admin, and redirected again — infinite loop. Added /forbidden to the pass-through list alongside /login. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,8 +4,8 @@ import type { NextRequest } from 'next/server';
|
||||
export async function middleware(req: NextRequest) {
|
||||
const { pathname } = req.nextUrl;
|
||||
|
||||
// Pass through the login page and API calls
|
||||
if (pathname.startsWith('/login') || pathname.startsWith('/api/')) {
|
||||
// Pass through the login page, forbidden page, and API calls
|
||||
if (pathname.startsWith('/login') || pathname.startsWith('/forbidden') || pathname.startsWith('/api/')) {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user