/
githubmirror
/
next.js
Обзор
Документация
Войти
/
githubmirror
/
next.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
canary
errors/invalid-route-source.mdx
56 строк
1 KB
Jiwon Choi
docs: Deprecation of Middleware (#84710)
17 окт 2025, 21:03
Не верифицирован
17 окт 2025, 21:03
bc59f21
Код
Авторство
О чём код?
--- title: 'Invalid Custom Route `source`' --- ## Why This Error Occurred A pattern could not be parsed when defining custom routes or a proxy `matcher`. This could have been due to trying to use normal `RegExp` syntax like negative lookaheads (`?!exclude`) without following [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp)'s syntax. ## Possible Ways to Fix It Wrap the `RegExp` part of your `source` as an un-named parameter. ### Custom Routes **Before** ```js { source: '/feedback/(?!general)', destination: '/feedback/general' } ``` **After** ```js { source: '/feedback/((?!general).*)', destination: '/feedback/general' } ``` ### Proxy **Before** ```ts filename="proxy.ts" const config = { matcher: '/feedback/(?!general)', } ``` **After** ```ts filename="proxy.ts" const config = { matcher: '/feedback/((?!general).*)', } ``` ## Useful Links - [path-to-regexp](https://github.com/pillarjs/path-to-regexp) - [un-named parameters](https://github.com/pillarjs/path-to-regexp#unnamed-parameters)