mirror of
https://github.com/lingke-net/koring-space.git
synced 2026-09-12 05:45:17 +08:00
20 lines
505 B
TypeScript
20 lines
505 B
TypeScript
import type { NextRequest } from "next/server";
|
|
import { NextResponse } from "next/server";
|
|
|
|
export function middleware(request: NextRequest) {
|
|
const { pathname } = request.nextUrl
|
|
|
|
if (pathname.startsWith("/rivfox-admin")) {
|
|
const isAdmin = request.cookies.get("rivfox-admin")?.value === "a2zFc9YTHpgiOxRH4"
|
|
|
|
if (!isAdmin) {
|
|
return NextResponse.rewrite(new URL("/404", request.url))
|
|
}
|
|
}
|
|
|
|
return NextResponse.next()
|
|
}
|
|
|
|
export const config = {
|
|
matcher: "/rivfox-admin/:path*",
|
|
} |