first commit

This commit is contained in:
Lee
2024-09-08 22:35:32 +01:00
parent 5d86ed4b26
commit c8a7aa7d1d
51 changed files with 5299 additions and 5179 deletions

20
src/middleware.ts Normal file
View File

@ -0,0 +1,20 @@
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
export function middleware(request: NextRequest) {
const { pathname } = request.nextUrl;
const cookies = request.cookies;
const playerIdCookie = cookies.get("playerId");
if (pathname == "/") {
if (playerIdCookie) {
return NextResponse.redirect(new URL(`/player/${playerIdCookie.value}/top/1`, request.url));
} else {
return NextResponse.redirect(new URL("/search", request.url));
}
}
}
export const config = {
matcher: "/((?!api|_next/static|_next/image|favicon.ico).*)",
};