feat(core): add support for array of global prefixes #16102
+159
−46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
PR Type
What is the current behavior?
Issue Number: #16095
setGlobalPrefix()only accepts a single string prefix. Users who need to expose the same API under multiple base paths (e.g., for different deployment environments) previously used regex-style prefixes like(prefixOne|prefixTwo), which are no longer supported by path-to-regexp v8 in NestJS v11.What is the new behavior?
setGlobalPrefix()now accepts either a string or an array of strings:This provides a migration path for users who previously relied on regex-style prefixes.
Changes:
INestApplication.setGlobalPrefix()interface to acceptstring | string[]getGlobalPrefixes()method toApplicationConfigto retrieve all prefixesRoutePathFactoryto generate paths for each prefix in the arrayRouteInfoPathExtractorto generate middleware paths for all prefixesDoes this PR introduce a breaking change?
The change is backward compatible - existing code using a single string prefix will continue to work.