【发布时间】:2023-04-08 10:46:01
【问题描述】:
我尝试使用我自己的 webpack 设置和配置重新创建一个使用 create-react-app 完成的 React 应用程序。一切正常,直到我遇到以下内容安全策略问题:
Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'none'". Either the 'unsafe-inline' keyword, a hash ('sha256-ThhI8UaSFEbbl6cISiZpnJ4Z44uNSq2tPKgyRTD3LyU='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
我尝试在项目 public/index/html 中使用不同的参数在元标记中设置 CSP 标头,但没有结果。有时页面甚至没有显示。
【问题讨论】:
标签: reactjs express content-security-policy