youtube v3 api 搜索在 Chrome 中失败但在 Firefox 中有效

youtube v3 api search fails in Chrome but works in Firefox

我们的应用程序 Accessible-Youtube 多年来一直运行良好。现在它只适用于 Firefox。 Chrome目前的失败点是在搜索视频的时候。代码如下:

$.ajax(
      "https://www.googleapis.com/youtube/v3/search?part=snippet&q=" +
        q +
        "&type=video&videoEmbeddable=true&key=OURKEYISHERE",
      {
        type: "GET",
        cache: false,
        success: function (data, status, jqxhr) {
          build(data);
        },
        error: function (data, status, jqxhr) {
          alert("An unknown error occured! Are you connected to the internet?");
        },
      }
    );

在 Firefox 中这工作正常。在 Chrome 中,我们收到带有消息

的 403 响应
{
  "error": {
    "code": 403,
    "message": "Requests from referer https://www.cs.unc.edu/ are blocked.",
    "errors": [
      {
        "message": "Requests from referer https://www.cs.unc.edu/ are blocked.",
        "domain": "global",
        "reason": "forbidden"
      }
    ],
    "status": "PERMISSION_DENIED"
  }
}

我怀疑这一定是最近对 Chrome 处理 cookie and/or 跨源请求的方式进行了更改。

我发现了问题。 Chrome 现在仅发送引用字段中的域。 Firefox 发送页面的完整路径。

我对 API 键进行了完整路径限制。当我将限制更改为只需要域时,它又开始工作了。

这似乎是 Chrome 相对于 API 的突破性变化。