Download ARTEX-main/web/src/proxy.ts from ghostai1/WardenPEN: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/ghostai1/WardenPEN/resolve/main/ARTEX-main/web/src/proxy.ts
- Command line
-
hf download hf://ghostai1/WardenPEN/ARTEX-main/web/src/proxy.ts
-
curl -L -o proxy.ts https://huggingface.co/ghostai1/WardenPEN/resolve/main/ARTEX-main/web/src/proxy.ts
1.18 kB
| import { NextResponse } from "next/server"; | |
| import type { NextRequest } from "next/server"; | |
| const AUTH_PAGES = ["/login", "/setup"]; | |
| export function proxy(request: NextRequest) { | |
| // Mock demo: no real login; allow every page (the client-side auth guard also allows through). | |
| if (process.env.NEXT_PUBLIC_MOCK === "1") return NextResponse.next(); | |
| const { pathname } = request.nextUrl; | |
| const token = request.cookies.get("artex_token")?.value; | |
| const isAuthPage = AUTH_PAGES.some((p) => pathname === p || pathname.startsWith(`${p}/`)); | |
| // Not logged in → redirect to the login page | |
| if (!token && !isAuthPage) { | |
| return NextResponse.redirect(new URL("/login", request.url)); | |
| } | |
| // Logged in while visiting the login/setup pages → redirect to the main UI | |
| if (token && isAuthPage) { | |
| return NextResponse.redirect(new URL("/function/tasks", request.url)); | |
| } | |
| return NextResponse.next(); | |
| } | |
| export const config = { | |
| // Skip Next.js internal routes, API routes, favicon, and static files under public/ (images, fonts, etc.) | |
| matcher: ["/((?!_next/static|_next/image|favicon\\.ico|api/|.*\\.(?:png|jpg|jpeg|gif|webp|svg|ico|woff2?|ttf|otf)$).*)"], | |
| }; | |