Part 14 / Topic 2 of 6
The convention: one file, one function, an optional config
proxy.ts lives at the project root — a sibling of app/, not inside it:
harness/
├── app/
├── proxy.ts ← here
└── ...
The installed docs are explicit that only one proxy.ts is supported per project — organize complex logic into separate modules and import them into this one entry point, rather than expecting multiple proxy files to compose. This harness's own file stays in one piece, scoped narrowly (section 5) to keep it simple:
// harness/proxy.ts (excerpt — full file: examples/01-proxy.ts)
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
export function proxy(request: NextRequest) {
// ... sections 3-4 ...
}
export const config = {
matcher: ["/status", "/status/:path*"],
};
Done here? The practice set for Part 14 — including the solutions — is on the part page.