【发布时间】:2021-05-20 21:22:59
【问题描述】:
不久前,我创建了一个“新标签,chrome 扩展”,它正在运行一个 React 应用程序。此扩展的功能之一是 Twitch 播放器,可以使用 iFrame 打开流以观看流。数据和 url 从开放的 Twitch API 中检索。这已经运行了很长一段时间,但大约一个月前它由于某种原因停止了工作。
当我打开流时,我收到以下错误消息:
拒绝框架“https://embed.twitch.tv/”,因为祖先 违反以下内容安全政策指令: “框架祖先 https://”。
值得注意的是,播放器在我只是运行 React 应用程序时工作,因此它与 Chrome 扩展程序有关。
我对此问题进行了一些研究,发现这是 iFrame 中如何指定父级和引用者的一些问题。 iFrame 看起来像这样,其中大部分是在我构建和运行扩展时自动生成的。
<iframe src="https://embed.twitch.tv?autoplay=true&channel=<a channel>&height=720px&layout=video-with-chat&muted=false&parent=<id of my chrome extension>&referrer=chrome-extension%3A%2F%<id of my chrome extension>%2Fbuild%2Findex.html&style=%5Bobject%20Object%5D&targetId=twitch-embed&width=1280px" allowfullscreen="" scrolling="no" frameborder="0" allow="autoplay; fullscreen" title="Twitch" sandbox="allow-modals allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox" width="1280px" height="720px"></iframe>
由于我找不到任何有助于解决问题的方法,我想我尝试发布一个新帖子。谁能帮我解决这个问题?
【问题讨论】:
标签: google-chrome iframe twitch