【发布时间】: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