Limiting CSP header to HTML responses only #146
Replies: 6 comments 4 replies
-
Hey, That sounds interesting indeed. What are your thoughts @danielroe ? |
Beta Was this translation helpful? Give feedback.
-
@Baroshem Not to be implemented? |
Beta Was this translation helpful? Give feedback.
-
Hey, there was no interest in this discussion for about 5 months so I decided to close it. Are you looking for this feature? |
Beta Was this translation helpful? Give feedback.
-
Hey @Baroshem Interestingly fix/nonce-ssg does exactly what he was suggesting, i.e. send the CSP header with an empty string on pre-rendered routes. Even more interesting is his suggestion that only |
Beta Was this translation helpful? Give feedback.
-
PR #304 fully implements |
Beta Was this translation helpful? Give feedback.
-
Closing as it was released with 1.0.0-rc.5 :) |
Beta Was this translation helpful? Give feedback.
-
Currently, if we enable the CSP header via the module, it adds the CSP header to all the responses including the static assets from _nuxt directory. We can override that by setting the header to an empty string in Nitro's routeRules but that still sends the header with the response, just as an empty string. We could also define the route for the CSP config itself, but that's tricky e.g. in my use-case where there is just one catch-all route and the pages are dynamically served with content from a headless CMS.
IMO, the CSP header should only be applied to HTML documents. So that the header is not present at all in other kinds of resources served by Nitro.
Beta Was this translation helpful? Give feedback.
All reactions