Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fastify-adapter): middleware not executed when root path is excluded #13797

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

patrickacioli
Copy link

@patrickacioli patrickacioli commented Jul 18, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • 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: #13401 , #11572

By using FastifyAdapter and setting a route config with exclude and prefix the middleware stops begin executed
For reproduction see tests in https://github.com/xtrinch/nestjs-middleware-issue-demo provided by @xtrinch

The behavior occurs because during the normalization performed on the pathname, it is not taken into account whether the application instance was configured to handle a prefix.

What is the new behavior?

These changes guarantee that when the Adapter is registered with a prefix, the normalization of the pathname will be taken into account when generating the regex expression.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Note: Given the @fastify/middie behavior described in docs the middleware will receive raw request and response objects, but controller will receive the wrapper object. With this in mind, to access this objects modified in middleware in controller instances, needs to access the raw object, otherwise, the wrapper will note have the changes executed by middleware.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 3eee6883-ff5f-45f2-838b-387f7124ce08

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 92.208%

Totals Coverage Status
Change from base Build d60c66a1-ca4c-4b6a-b0cc-2fd524f244cf: 0.0%
Covered Lines: 6745
Relevant Lines: 7315

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants