有没有人成功地将 CSP 添加到 Nuxt 应用程序?
我尝试过Helmet,但它似乎与 nuxt.config.js 文件不兼容。
还尝试在 Nuxt的Render 属性上添加 csp ,但在某些脚本需要 nonce 时遇到了问题。
这是我的 nuxt.config.js 中 Render 属性的要点,这对吗?
你如何在 Nuxt 中生成随机数?
render: {
csp: {
hashAlgorithm: 'sha256',
policies: {
'script-src': [
'self',
'unsafe-inline',
'http://assets.adobedtm.com',
'https://cdn.polyfill.io/',
'https://www.everestjs.net',
'https://www.google-analytics.com',
'http://localhost:8001',
"'sha256-<hash>'"
],
},
reportOnly: false,
addMeta: true
}
},
Run Code Online (Sandbox Code Playgroud)