forked from R44VC0RP/teslanav.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.ts
More file actions
44 lines (36 loc) · 975 Bytes
/
Copy pathproxy.ts
File metadata and controls
44 lines (36 loc) · 975 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { PROJECT_SHUTDOWN_ENABLED } from "@/lib/shutdown";
export function proxy(request: NextRequest): NextResponse {
if (!PROJECT_SHUTDOWN_ENABLED) {
return NextResponse.next();
}
const { pathname } = request.nextUrl;
if (pathname.startsWith("/api/")) {
return NextResponse.json(
{
error:
"TeslaNav is currently shut down. API access is temporarily disabled.",
},
{
status: 503,
headers: {
"Cache-Control": "no-store",
},
}
);
}
if (pathname === "/") {
return NextResponse.next();
}
if (pathname.startsWith("/_next/")) {
return NextResponse.next();
}
const url = request.nextUrl.clone();
url.pathname = "/";
url.search = "";
return NextResponse.redirect(url);
}
export const config = {
matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
};