forked from FailproofAI/failproofai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.ts
More file actions
24 lines (20 loc) · 715 Bytes
/
Copy pathproxy.ts
File metadata and controls
24 lines (20 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { NextRequest, NextResponse } from "next/server";
export async function proxy(request: NextRequest): Promise<NextResponse> {
const { pathname } = request.nextUrl;
if (pathname === "/") {
const disabled = (process.env.FAILPROOFAI_DISABLE_PAGES ?? "")
.split(",")
.map((s) => s.trim())
.filter(Boolean);
if (!disabled.includes("policies")) {
return NextResponse.redirect(new URL("/policies", request.url));
}
if (!disabled.includes("projects")) {
return NextResponse.redirect(new URL("/projects", request.url));
}
}
return NextResponse.next();
}
export const config = {
matcher: ["/((?!_next/static|_next/image|favicon\\.ico|icon\\.png).*)"],
};