Next.js 16 introduces proxy.ts (replacing middleware) at project root to proxy API routes to external services, handling auth, CORS, and routing cleanly without third-party libs.
Create proxy.ts in your project root (or src/) and export a proxy function that intercepts API requests. Use NextResponse to rewrite/redirect to your backend, add auth headers, or proxy full paths. Add config.matcher: '/api/:path*' to target only API routes. This runs before API handlers, perfect for BFF patterns and hiding backend URLs.
.png)

.png)
