scoresaber-reloaded-v2/src/middleware.ts
Liam 84c25cafd4
All checks were successful
deploy / deploy (push) Successful in 56s
cleanup
2023-10-23 07:01:55 +01:00

23 lines
650 B
TypeScript

import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
export function middleware(request: NextRequest) {
// todo: make this redirect to the users profile if they have a profile selected
if (request.nextUrl.pathname == "/") {
return NextResponse.redirect(new URL("/search", request.url));
}
const requestHeaders = new Headers(request.headers);
requestHeaders.set("x-url", request.url);
return NextResponse.next({
request: {
// New request headers
headers: requestHeaders,
},
});
}
export const config = {
matcher: "/((?!api|_next/static|_next/image|favicon.ico).*)",
};