为了避免发生CORS错误,是否需要运行iframe嵌入式youtube视频的服务器?

问题描述

我正在通过非托管的index.html页面运行 iframe 嵌入式YT视频的马赛克,只需在浏览器中打开文件即可。这适用于大多数视频,但是,某些实时流(例如 Euronews,Bloomberg,ABC澳大利亚)在打开时开始显示无用消息: Video unavailable 在正常的YT页面中运行正常。 Google自己的文档并没有说出为什么会发生这种情况。

代码是:

...
<iframe width="560" height="315" 
src="https://www.youtube.com/embed/W1ilCy6XrmI?cc_load_policy=3&autoplay=0&mute=1&origin=https://www.abc.net.au" 
frameborder="0" allowfullscreen></iframe>
...

打开调试器,显示

  1. CORS错误消息:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at
https://googleads.g.doubleclick.net/pagead/id. 
(Reason: CORS request did not succeed).
  1. 警告:
Some cookies are misusing the recommended “sameSite“ attribute 
Cookie “SIDCC” will be soon rejected because it has the “sameSite” 
attribute set to “none” or an invalid value,without the “secure” 
attribute. To kNow more about the “sameSite“ attribute,read 
https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite

参考文献:
有很多参考文献,但大多数都已经过时/不相关,而且都没有回答我的问题。


我的问题:

是否可以在 localhost 上提供上述代码
(甚至需要吗?我该怎么办?)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)