Respect route-level contentSecurityPolicy: false
setting
#262
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.
Hello and thanks for great project!
I noticed, that currently the
contentSecurityPolicy: false
is allowed by types (since it is a original'shelmet
valid configuration), but is not actually respected by@fastify/helmet
and always falls back tohelmet
defaults.So now it is not possible to remove
Content-Security-Policy
header for one specific route, even though configuration typings are allowing for that and the rest of the headers supports that - which is pretty confusing 😢It happens because of how CSP Nonce generation feature is currently implemented and i have added a fix for that + test, so
contentSecurityPolicy: false
is also respected at individual route level.Documentation is not changed, since don't think it is needed - current docs are describing the way to pass custom
helmet
configration for specific routes andcontentSecurityPolicy: false
is a valid case ofhelmet
configuration.I had checked that in the checklist anyway, since there is no other option to highlight that documentation doesn't need any further changes in this PR
Checklist
npm run test
andnpm run benchmark
and the Code of conduct