---
title: Nested Proxy
---
## Why This Error Occurred
You are defining a Proxy file in a location different from `<root>/proxy`, which is not allowed.
While in beta, a Proxy file under specific pages would _only_ be executed when pages below its declaration were matched, allowing nesting Proxy files. Based on customer feedback, we have replaced this API with a single root Proxy.
## Possible Ways to Fix It
Declare your Proxy in the root folder and use `NextRequest` parsed URL to define which path the Proxy should be executed for.
For example, a Proxy at `pages/about/_proxy.ts` can move the logic to `<root>/proxy.ts` in the root of your repository. Then, a conditional statement can be used to only run the Proxy when it matches the `about/*` path:
```ts filename="proxy.ts"
import type { NextRequest } from 'next/server'
export function proxy(request: NextRequest) {
if (request.nextUrl.pathname.startsWith('/about')) {
// This logic is only applied to /about
}
if (request.nextUrl.pathname.startsWith('/dashboard')) {
// This logic is only applied to /dashboard
}
}
```
If you have more than one Proxy, you should combine them into a single file and model their execution depending on the incoming request.