Files
wfh/src/middleware.ts

26 lines
756 B
TypeScript
Raw Normal View History

2026-03-12 17:09:22 -05:00
import { NextRequest, NextResponse } from "next/server";
export function middleware(request: NextRequest) {
// Simple check for auth routes or static files
if (
request.nextUrl.pathname.startsWith('/api/auth') ||
request.nextUrl.pathname.startsWith('/_next') ||
request.nextUrl.pathname === '/favicon.ico'
) {
return NextResponse.next();
}
const token = request.cookies.get('next-auth.session-token') ||
request.cookies.get('__Secure-next-auth.session-token');
if (!token && request.nextUrl.pathname !== '/') {
return NextResponse.redirect(new URL('/', request.url));
}
return NextResponse.next();
}
export const config = {
matcher: ['/((?!api/auth|_next/static|_next/image|favicon.ico).*)'],
};