/
githubmirror
/
next.js
Обзор
Документация
Войти
/
githubmirror
/
next.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
canary
errors/nested-proxy.mdx
31 строка
1 KB
Jiwon Choi
docs: Replace Middleware docs to Proxy (#84709)
17 окт 2025, 17:13
Не верифицирован
17 окт 2025, 17:13
71ce95d
Код
Авторство
О чём код?
--- 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.