Skip to content

Latest commit

 

History

History
58 lines (39 loc) · 1014 Bytes

invalid-route-source.md

File metadata and controls

58 lines (39 loc) · 1014 Bytes

Invalid Custom Route source

Why This Error Occurred

When defining custom routes, or a middleware matcher, a pattern could not be parsed.

This could have been due to trying to use normal RegExp syntax like negative lookaheads (?!exclude) without following path-to-regexp's syntax for it.

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'
}

Middleware:

Before

const config = {
  matcher: '/feedback/(?!general)',
}

After

const config = {
  matcher: '/feedback/((?!general).*)',
}

Useful Links