Repository navigation
fix(core): run middleware on subpaths next to an all-methods route - #18407
Merged
kamilmysliwiec merged 1 commit intoNov 5, 2026
Merged
Conversation
RequestMethod.ALL is an exact mount. A plain forRoutes string on Express
and the node adapter is a prefix mount, so removing "shop/admin" next to
{ path: "shop/:id", method: ALL } left every path below it without the
middleware.
Keep the string, as 12.3.2 did. The exact path then matches both routes
and runs the middleware twice, as on 12.3.2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Since 12.3.3 (#18357), this call no longer runs the middleware for
/shop/admin/reportson Express and the node adapter:With a middleware that answers 401,
GET /shop/admin/reportsnow returns 200 from the handler. On 12.3.2 the middleware runs for it, because a plain string is mounted withuse(), which also matches subpaths. #18357 describes routes declared for a specific method, but its check also removes a plain string next to a parameterizedRequestMethod.ALLroute.RequestMethod.ALLisapp.all/useExact: it matches/shop/admin, not the paths below it.Issue Number: N/A
What is the new behavior?
A plain string is only removed next to another plain string, as before #18357. A route of a specific method next to
RequestMethod.ALLis still removed. The new e2e cases run on Express and the node adapter. Fastify anchors middleware paths, so a string without a wildcard never reaches subpaths there.Does this PR introduce a breaking change?
On Express and the node adapter, paths below the string run the middleware again, as on 12.3.2. A path matched by both kept routes, such as
/shop/admin, runs it twice on every adapter, also as on 12.3.2 (once on 12.3.3). 77d28b6 accepts the same for/files/:idnext to/files/{*path}. On Fastify that double run is the only change. SharinghandledRequestsbetween the all-methods routes of oneforRoutes()call would keep one run, but the first mount would then decide what the middleware sees (on Express, noreq.params.idwhen the string comes first), so I left it out.Other information
I found this reading #18357, not from a report, and a GitHub code search turned up no public app with this exact pair. For an app that has it, a patch upgrade silently skips the middleware on those subpaths.