1- import { NextResponse } from ' next/server'
2- import type { NextRequest } from ' next/server'
1+ import { NextResponse } from " next/server"
2+ import type { NextRequest } from " next/server"
33
44/**
55 * Middleware to handle 404s by redirecting to the home page
@@ -10,19 +10,19 @@ export function middleware(request: NextRequest) {
1010 // We only want to handle 404s, not other pages
1111 // This check isn't foolproof but helps avoid redirecting existing pages
1212 const pathname = request . nextUrl . pathname
13-
13+
1414 // Check if this is a static asset or API route - we don't want to redirect these
1515 if (
16- pathname . startsWith ( ' /_next' ) ||
17- pathname . startsWith ( ' /api/' ) ||
18- pathname . startsWith ( ' /images/' ) ||
19- pathname . includes ( '.' ) // Likely a file, e.g. favicon.ico
16+ pathname . startsWith ( " /_next" ) ||
17+ pathname . startsWith ( " /api/" ) ||
18+ pathname . startsWith ( " /images/" ) ||
19+ pathname . includes ( "." ) // Likely a file, e.g. favicon.ico
2020 ) {
2121 return NextResponse . next ( )
2222 }
2323
2424 // Return a 301 (permanent) redirect to the home page
25- return NextResponse . redirect ( new URL ( '/' , request . url ) , 301 )
25+ return NextResponse . redirect ( new URL ( "/" , request . url ) , 301 )
2626}
2727
2828// Configure which paths this middleware will run on
@@ -36,6 +36,6 @@ export const config = {
3636 * 3. Static files (images, etc)
3737 * 4. System paths like _next, favicon.ico, etc.
3838 */
39- ' /((?!_next|api|images|favicon.ico).*)' ,
39+ " /((?!_next|api|images|favicon.ico).*)" ,
4040 ] ,
41- }
41+ }
0 commit comments