MCPcopy Create free account
hub / github.com/R44VC0RP/teslanav.com / proxy

Function proxy

proxy.ts:5–40  ·  view source on GitHub ↗
(request: NextRequest)

Source from the content-addressed store, hash-verified

3import { PROJECT_SHUTDOWN_ENABLED } from "@/lib/shutdown";
4
5export function proxy(request: NextRequest): NextResponse {
6 if (!PROJECT_SHUTDOWN_ENABLED) {
7 return NextResponse.next();
8 }
9
10 const { pathname } = request.nextUrl;
11
12 if (pathname.startsWith("/api/")) {
13 return NextResponse.json(
14 {
15 error:
16 "TeslaNav is currently shut down. API access is temporarily disabled.",
17 },
18 {
19 status: 503,
20 headers: {
21 "Cache-Control": "no-store",
22 },
23 }
24 );
25 }
26
27 if (pathname === "/") {
28 return NextResponse.next();
29 }
30
31 if (pathname.startsWith("/_next/")) {
32 return NextResponse.next();
33 }
34
35 const url = request.nextUrl.clone();
36 url.pathname = "/";
37 url.search = "";
38
39 return NextResponse.redirect(url);
40}
41
42export const config = {
43 matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected