nest icon indicating copy to clipboard operation
nest copied to clipboard

fix(core): Improve middleware route exclusion for dynamic endpoints

Open sapenlei opened this issue 11 months ago • 7 comments
trafficstars

fixes #13593

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
  • [x] Tests for the changes have been added (for bug fixes / features)
  • [ ] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • [x] Bugfix
  • [ ] Feature
  • [ ] Code style update (formatting, local variables)
  • [ ] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [ ] CI related changes
  • [ ] Other... Please describe:

What is the current behavior?

Issue Number: #13593

What is the new behavior?

The middleware route exclusion now correctly handles the coexistence of static and dynamic routes:

  • Static routes (e.g., /all) are not affected by dynamic route exclusions
  • Dynamic routes (e.g., /:id) can be excluded without impacting other routes
  • Middleware correctly runs for non-excluded routes while skipping excluded ones

For example, when excluding /:id route:

  • Middleware runs for /all endpoint
  • Middleware skips /:id endpoint

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

Other information

sapenlei avatar Nov 24 '24 03:11 sapenlei