【问题标题】:Apps Script Gadget on Google Site started throwing CORS errorsGoogle 网站上的 Apps 脚本小工具开始抛出 CORS 错误
【发布时间】:2014-04-19 11:15:01
【问题描述】:

我有一个包含多个页面的 Google 站点,所有页面都包含一个 Google Apps 脚本小工具。用户报告说,几个月前,Apps Script Gadgets 停止工作。我对它们进行了测试,发现 Apps Script 小工具可以正确加载并显示来自 UI 服务的内容,但是,当单击任何运行功能的按钮时,Apps Script Gadget 会挂起并且浏览器中显示控制台错误:

Uncaught SecurityError: Failed to read the 'frame' property from 'Window': Blocked a frame                      
with origin "https://sites.google.com" from accessing a frame with origin
"https://xxxxxxxxxxxxxxxx-a-sites-opensocial.googleusercontent.com".
Protocols, domains, and ports must match.

Google 是否更改了某种安全策略以防止向 Apps Script Scripts 发出跨域请求?有什么解决方法吗?

谢谢

学习

【问题讨论】:

  • 提供更多信息。您究竟是如何将脚本插入网站的?通过网址?网址是否以“脚本”或“网站”开头。
  • 使用 Google Apps 脚本小工具将脚本插入到站点中。网址以 script.google.com 开头
  • 我会尝试使用在另一个选项卡中打开 Apps Script Gadget 的链接作为解决方法。 <a href="https://URL to Your deployed AppsScript.com" target="_blank">My Gadget Name</a>
  • 如果你能提供你的实现,我很乐意多看一下(我最近在一个项目中与 Google Gadgets 合作过)。

标签: javascript google-chrome google-apps-script cors google-sites


【解决方案1】:

我能找到解决此问题的唯一方法是将小工具替换为在新页面中打开 Apps 脚本 URL 的链接。

【讨论】:

    猜你喜欢
    • 2023-04-03
    • 1970-01-01
    • 2014-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-11
    • 2023-04-07
    • 1970-01-01
    相关资源
    最近更新 更多