feat: [NestJS] Fastify global prefix support #704
Merged
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.
Fixes #607.
Apparently #592 doesn't work with Fastify and #639 adds Fastify support.
But both PRs fail loading the static folder correctly when global prefix doesn't start with a forward slash.
It was mentioned here #592 (comment) with #607 (comment) as the solution.
This PR does 2 things:
adapter.basePath
to correctly load the static folder for both Express and Fastify.prefix
option should be equal to theadapter.basePath
.I've setup 2 codesandboxes for you to verify this PR:
NestJS + Express: https://codesandbox.io/p/devbox/vigilant-tdd-nhjg2r
Preview: https://nhjg2r-3000.csb.app/api/queues
NestJS + Fastify: https://codesandbox.io/p/devbox/naughty-kepler-w38fhq
Preview: https://w38fhq-3000.csb.app/api/queues
main.ts
: You can change the global prefix here with/without a leading slash. Or comment out the setGlobalPrefix method to see that it still works without it.app.module.ts
: Change the route to something else if you want.Both use
"@bull-board/nestjs": "github:dimbslmh/bull-board-nestjs",