22 lines
542 B
TypeScript
22 lines
542 B
TypeScript
import { NextResponse, type NextRequest } from "next/server";
|
|
|
|
import { MOCK_SESSION_COOKIE_NAME } from "@/lib/mock-auth";
|
|
import { shouldRedirectDashboardRequest } from "@/lib/proxy-auth";
|
|
|
|
export function proxy(request: NextRequest) {
|
|
if (
|
|
shouldRedirectDashboardRequest(
|
|
request.nextUrl.pathname,
|
|
request.cookies.get(MOCK_SESSION_COOKIE_NAME)?.value,
|
|
)
|
|
) {
|
|
return NextResponse.redirect(new URL("/", request.url));
|
|
}
|
|
|
|
return NextResponse.next();
|
|
}
|
|
|
|
export const config = {
|
|
matcher: "/dashboard/:path*",
|
|
};
|