Closed alucebur closed 1 year ago
this seems to be a regression introduced on PR #10390 (v9.3.2)
v9.3.0 went fine
Would you like to create a PR for this issue?
Let's track this here https://github.com/nestjs/nest/pull/11832
Any plan to merge the referenced PR? I hit this bug and was happy to see that there is a fix available but unfortunately it's not released yet.
Thanks!
Any updates on this?
Is there an existing issue for this?
Current behavior
Middleware is applied twice when using setGlobalPrefix with the route "/" excluded, for every route except "/".
Minimum reproduction code
https://codesandbox.io/p/sandbox/determined-ben-7357wt
Steps to reproduce
There are 4 routes; three of them are prefixed by "api" global prefix, and one is excluded ("/").
There is a middleware that logs the request, showing baseUrl and originalUrl from the petition.
When calling "/" route, middleware is executed once.
When calling any other route, middleware is executed twice, the last of them with baseUrl empty (check logs in the terminal).
If we edit the excluded route from "/" to "one", everything works as expected, being the middleware only executed once for every route.
Expected behavior
When setting a global prefix and excluding the route "/", the middleware is executed only once for every route in the application.
Package
Other package
No response
NestJS version
10.0.0
Packages versions
Node.js version
16.17.0
In which operating systems have you tested?
Other
The issue has also been reproduced using Nest v9.4 and Node 18, under WSL.