(request: NextRequest)
| 3 | import { PROJECT_SHUTDOWN_ENABLED } from "@/lib/shutdown"; |
| 4 | |
| 5 | export 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 | |
| 42 | export const config = { |
| 43 | matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"], |
nothing calls this directly
no outgoing calls
no test coverage detected