Open kylejramstad opened 3 years ago
Here is the specific error from the console:
Refused to load the script '
' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'script-src-elem' was not explicitly set, so 'default-src' is used as a fallback.
I tried with a small test and there is no CSP issue.
You can download the source code here: test.zip
Run it and access https://localhost:3000/static.
The CSP issue only happened when upgraded to helmet@^5.0.0
as that version enabled CSP by default.
That is not an http2-express-bridge
issue.
You can disable CSP in helmet@^5.0.0
:
app.use(
require('helmet')({
contentSecurityPolicy: false,
})
)
Or you can set it to report only in helmet@^5.0.0
:
app.use(
require('helmet').contentSecurityPolicy({
reportOnly: true,
})
)
When converting my app to use htt2-express-bridge, it seems to be setting the content security policy headers to block everything. My pages are not allowed to load their own scripts or even a css file.
My project is https://github.com/kylejramstad/garage-pi-v2. In my server.js file I have made the following changes in CODE :