rsnext/errors/max-custom-routes-reached.md
JJ Kasper 14dd7c2954
Add warning for large number of routes (#27214)
This adds a warning when more than 1024 routes are added since it can have performance impacts and includes a document that we can add suggestions to reduce the number of routes being added. 

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes
2021-07-16 14:59:54 +00:00

906 B

Max Custom Routes Reached

Why This Error Occurred

The number of combined routes from headers, redirects, and rewrites exceeds 1000. This can impact performance because each request will iterate over all routes to check for a match in the worst case.

Possible Ways to Fix It

  • Leverage dynamic routes inside of the pages folder to reduce the number of rewrites needed
  • Combine headers routes into dynamic matches e.g. /first-header-route /second-header-route -> /(first-header-route$|second-header-route$)