Initial commit
This commit is contained in:
35
middleware.ts
Normal file
35
middleware.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
const { pathname } = request.nextUrl;
|
||||
|
||||
// Skip middleware for admin routes, API routes, static files, and the lock page itself
|
||||
if (
|
||||
pathname.startsWith('/admin') ||
|
||||
pathname.startsWith('/api') ||
|
||||
pathname.startsWith('/_next') ||
|
||||
pathname.startsWith('/icon.svg') ||
|
||||
pathname === '/lock'
|
||||
) {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
// The actual password lock check will be done on the client side
|
||||
// This middleware is kept simple and only used for future extensions
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
// Configure which routes use this middleware
|
||||
export const config = {
|
||||
matcher: [
|
||||
/*
|
||||
* Match all request paths except for the ones starting with:
|
||||
* - api (API routes)
|
||||
* - _next/static (static files)
|
||||
* - _next/image (image optimization files)
|
||||
* - favicon.ico (favicon file)
|
||||
*/
|
||||
'/((?!api|_next/static|_next/image|favicon.ico).*)',
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user