【问题标题】:Cannot embed youtube video (Cookie Error: samesite attribute)无法嵌入 youtube 视频(Cookie 错误:samesite 属性)
【发布时间】:2020-07-19 19:21:56
【问题描述】:

当我在嵌入的 youtube 视频上按播放时,我得到“视频不可用”。我在控制台中遇到的错误是这样的:

A cookie associated with a cross-site resource at https://youtube.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.

我的 HTML 代码如下:

<iframe width="560" height="315" src={{ embedURL }} frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

我也尝试了硬编码的嵌入链接,但结果相同。我的标签中是否缺少属性?

【问题讨论】:

  • 这似乎是一个 youtube 问题。您可以使用 youtube 的无 cookie 版本,这可能会阻止此错误的发生。尝试www.youtube-nocookie.com/ 而不是www.youtube.com;
  • @Phiter 刚刚尝试使用 nocookie 网址。视频不可用再次显示,但这次控制台中没有错误。即使在 nocookie 网址上,视频也不可用。

标签: html flask


【解决方案1】:

您可以尝试使用www.youtube-nocookie.com/embed/+ VideoID。

例如https://www.youtube-nocookie.com/embed/N4Keb583jf0

小心,这是唯一应该一直有效的 URL 语法:你需要 www 和 /embed/...

在您的代码中,embedurl 将是:https://www.youtube-nocookie.com/embed/+VideoID(+ 表示“连接”)

【讨论】:

  • 嘿!欢迎来到 SO!尝试在您的答案周围包含更多细节,以使其更有用。见How to Answer
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-08-16
  • 1970-01-01
  • 2016-04-20
  • 2016-11-27
  • 2011-09-06
  • 2011-09-01
  • 2014-01-16
相关资源
最近更新 更多