【问题标题】:Content Security Policy does not respect meta tag内容安全政策不尊重元标记
【发布时间】:2021-03-22 08:16:54
【问题描述】:

我在部署的 React 应用程序的 Chrome 网络控制台中收到以下错误:

Refused to frame 'https://www.youtube.com/' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'frame-src' was not explicitly set, so 'default-src' is used as a fallback.

但是,我在index.html 中指定了frame-src,如下面的sn-p:

<meta http-equiv="Content-Security-Policy" content="frame-src https://www.youtube.com/">

错误的来源是 YouTube 嵌入,并且使用元标记,嵌入在 localhost 上可以正常工作。什么可能导致此错误仅出现在已部署的 React 应用程序上?

【问题讨论】:

    标签: reactjs google-chrome youtube content-security-policy production


    【解决方案1】:

    通过在服务器上添加 Content-Security-Policy 标头来修复它。所以这毕竟不是前端代码的问题。

    【讨论】:

      猜你喜欢
      • 2019-03-14
      • 2019-04-15
      • 2015-07-22
      • 2016-10-03
      • 2017-04-24
      • 2021-12-25
      • 2020-12-29
      • 2016-07-19
      相关资源
      最近更新 更多