Spaces:
Sleeping
Sleeping
import { NextResponse } from 'next/server' | |
import type { NextRequest } from 'next/server' | |
// This function can be marked `async` if using `await` inside | |
export function middleware(request: NextRequest) { | |
if (request.nextUrl.pathname === '/') { | |
return NextResponse.redirect(new URL('/login', request.url)) | |
} | |
return NextResponse.next(); | |
} | |
// Ensure the middleware is only called for relevant paths. | |
export const config = { | |
matcher: [ | |
/* | |
* Match all request paths except for the ones starting with: | |
* - _next/static (static files) | |
* - _next/image (image optimization files) | |
* - favicon.ico (favicon file) | |
*/ | |
'/((?!_next/static|_next/image|auth|monitoring|svgs|favicon.ico).*)', | |
], | |
}; |