19 lines
654 B
TypeScript
19 lines
654 B
TypeScript
import { NextResponse } from "next/server"
|
|
import type { NextRequest } from "next/server"
|
|
|
|
// This middleware runs on every request
|
|
export function middleware(request: NextRequest) {
|
|
// If the request is not for the home page, redirect to the home page
|
|
if (request.nextUrl.pathname !== "/" && !request.nextUrl.pathname.startsWith("/_next") && !request.nextUrl.pathname.match(/\.(ico|png|jpg|jpeg|svg|gif)$/)) {
|
|
return NextResponse.redirect(new URL("/", request.url))
|
|
}
|
|
|
|
return NextResponse.next()
|
|
}
|
|
|
|
// Configure the middleware to run on all routes
|
|
export const config = {
|
|
matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
|
|
}
|
|
|