The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { NextRequest, NextResponse } from "next/server"; |
| 2 | import { timezoneFromRequest, visitorTimezoneHeader } from "./src/VisitorTimezone.ts"; |
| 3 | |
| 4 | /** |
| 5 | * Next.js 16 / vinext `proxy.ts` (the `middleware.ts` file convention |
| 6 | * is deprecated). Trimmed to the routes this Alchemy example ships. |
| 7 | */ |
| 8 | export function proxy(request: NextRequest) { |
| 9 | if (request.nextUrl.pathname === "/admin") { |
| 10 | return new Response("Blocked by proxy", { status: 403 }); |
| 11 | } |
| 12 | |
| 13 | const requestHeaders = new Headers(request.headers); |
| 14 | requestHeaders.set(visitorTimezoneHeader(), timezoneFromRequest(request)); |
| 15 | |
| 16 | const response = NextResponse.next({ |
| 17 | request: { headers: requestHeaders }, |
| 18 | }); |
| 19 | response.headers.set("x-mw-ran", "true"); |
| 20 | return response; |
| 21 | } |
| 22 | |
| 23 | export const config = { |
| 24 | matcher: ["/", "/notes", "/use-cache", "/api/:path*", "/admin"], |
| 25 | }; |