Download frontend/middleware.ts from new-arc/vector: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/new-arc/vector/resolve/main/frontend/middleware.ts
- Command line
-
hf download hf://spaces/new-arc/vector/frontend/middleware.ts
-
curl -L -o middleware.ts https://huggingface.co/spaces/new-arc/vector/resolve/main/frontend/middleware.ts
1.11 kB
| import { NextResponse } from "next/server"; | |
| import type { NextRequest } from "next/server"; | |
| const PUBLIC_FILE = /\.(.*)$/; | |
| export function middleware(request: NextRequest) { | |
| const isLandingOnlyModeEnabled = | |
| process.env.NEXT_PUBLIC_LANDING_ONLY_MODE === "true"; | |
| if (!isLandingOnlyModeEnabled) { | |
| return NextResponse.next(); | |
| } | |
| const { pathname } = request.nextUrl; | |
| if ( | |
| pathname === "/" || | |
| pathname === "/status" || | |
| pathname.startsWith("/_next") || | |
| pathname.startsWith("/api/billing/webhook") || | |
| pathname.startsWith("/ingest/") || | |
| // Opt-outs (including mailbox one-click POSTs) must work in every mode. | |
| pathname === "/email/product-updates/unsubscribe" || | |
| PUBLIC_FILE.test(pathname) | |
| ) { | |
| return NextResponse.next(); | |
| } | |
| if (pathname.startsWith("/api")) { | |
| return NextResponse.json( | |
| { error: "SupoClip is in landing-page-only mode." }, | |
| { status: 503 } | |
| ); | |
| } | |
| const url = request.nextUrl.clone(); | |
| url.pathname = "/"; | |
| url.search = ""; | |
| return NextResponse.redirect(url); | |
| } | |
| export const config = { | |
| matcher: "/:path*", | |
| }; | |