-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Did you read the migration guide?
- I have read the whole migration guide
Is there an existing issue that is already proposing this?
- I have searched the existing issues
Potential Commit/PR that introduced the regression
No response
NestJS version
10.4.16 -> 11.1.9
Describe the regression
After migrating our application from NestJS v10 to v11, we encountered a breaking change related to the usage of setGlobalPrefix.
In NestJS v10 and earlier, our application relied on a regex-based global prefix to support two different deployment environments within the same codebase:
app.setGlobalPrefix('(prefixOne|prefixTwo)');This configuration worked as expected and allowed the same API to be exposed under two alternative base paths without duplicating controllers or builds.
After upgrading to NestJS v11, the application fails during bootstrap with the following error:
[2025-12-18 11:47:51] ERROR: [LegacyRouteConverter] Unsupported route path: "/(prefixOne|prefixTwo)/". In previous versions, the symbols ?, *, and + were used to denote optional or repeating path parameters. The latest version of "path-to-regexp" now requires the use of named parameters. For example, instead of using a route like /users/* to capture all routes starting with "/users", you should use /users/*path. For more details, refer to the migration guide.
It appears that setGlobalPrefix no longer supports RegExp-style paths due to changes introduced with the path-to-regexp upgrade. There is no clear migration path or documented alternative for supporting multiple global prefixes, which makes this a breaking change compared to v10 and forces restructuring of routing logic or controller duplication.
This document serves as a concise description of the issue encountered during migration.
Minimum reproduction code
No response
Input code
app.setGlobalPrefix('(prefixOne|prefixTwo)');Expected behavior
setGlobalPrefix should continue to support RegExp-style prefixes, as it did in NestJS v10, or provide an officially supported alternative for configuring multiple global base paths.
Other
No response