Spaces:
Runtime error
Runtime error
Download proxy.ts from Ali-Developments/COURTRIX: direct link, hf CLI and curl.
- Browser
- Download file 671 Bytes
-
https://huggingface.co/spaces/Ali-Developments/COURTRIX/resolve/main/proxy.ts
- Command line
-
hf download hf://spaces/Ali-Developments/COURTRIX/proxy.ts
-
curl -L -o proxy.ts https://huggingface.co/spaces/Ali-Developments/COURTRIX/resolve/main/proxy.ts
671 Bytes
| import type { NextRequest } from "next/server"; | |
| import { NextResponse } from "next/server"; | |
| import { SESSION_COOKIE_NAME } from "@/lib/constants"; | |
| export function proxy(request: NextRequest) { | |
| const { pathname } = request.nextUrl; | |
| if (!pathname.startsWith("/dashboard")) { | |
| return NextResponse.next(); | |
| } | |
| const hasSessionCookie = Boolean(request.cookies.get(SESSION_COOKIE_NAME)?.value); | |
| if (hasSessionCookie) { | |
| return NextResponse.next(); | |
| } | |
| const loginUrl = new URL("/login", request.url); | |
| loginUrl.searchParams.set("next", pathname); | |
| return NextResponse.redirect(loginUrl); | |
| } | |
| export const config = { | |
| matcher: ["/dashboard/:path*"], | |
| }; | |