invalid-route-source.mdx
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's syntax.
Possible Ways to Fix It
Wrap the RegExp part of your source as an un-named parameter.
Custom Routes
Before
{
source: '/feedback/(?!general)',
destination: '/feedback/general'
}
After
{
source: '/feedback/((?!general).*)',
destination: '/feedback/general'
}
Proxy
Before
const config = {
matcher: '/feedback/(?!general)',
}
After
const config = {
matcher: '/feedback/((?!general).*)',
}
Useful Links
Rendered from the public repository vercel/next.js on GitHub; content belongs to its authors. Cached for up to an hour.