Configuration
Proxy file convention
Place proxy.ts beside app or pages, or beside them under src. The Next.js 16 Proxy convention uses Node.js; do not export a runtime override. Use it for request routing and lightweight checks rather than slow data fetching. Independently authorize protected handlers and actions. Source: https://nextjs.org/docs/app/api-reference/file-conventions/proxy. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.
Formal Syntax & Structure
nextjs syntaxnextjs
export function proxy(request: NextRequest)Working Example
Example Snippetnextjs
import { NextResponse, type NextRequest } from 'next/server';export function proxy(request: NextRequest) { const response = NextResponse.next(); response.headers.set('X-Catalog-Route', 'yes'); return response;}export const config = { matcher: ['/catalog/:path*'] };