Add support for nested proxy.ts files inside Route Groups #88680
ahmedmbarektorjmene
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Goals
Non-Goals
Background
Today, Next.js encourages colocation via the App Router, Route Groups, and nested layouts. However, server-side proxying (e.g., request forwarding, auth token injection, header normalization, or environment-based routing) is typically centralized in a single root-level construct. This creates friction when different route groups require distinct proxy behavior (for example,
(auth)vs(admin)vs(public)routes).Current alternatives include:
proxy.tswith complex conditional logic based on pathname.These approaches reduce clarity and break the otherwise strong colocation model of the App Router.
Proposal
Allow
proxy.tsto be discovered and applied hierarchically within theapp/directory, similar tolayout.tsxandloading.tsx:proxy.tsplaced inside a Route Group or route segment applies only to that subtree.app/proxy.ts(if present) acts as the default fallback.Example
All reactions