【发布时间】:2020-05-19 13:15:12
【问题描述】:
是否有人成功将 CSP 添加到 Nuxt 应用?
我尝试了Helmet,但它似乎与 nuxt.config.js 文件不兼容。
还尝试在 Nuxt 中的 Render property 上添加 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
}
},
【问题讨论】:
-
您能分享一下您是如何解决这个问题的吗?
标签: vue.js nuxt.js content-security-policy nonce