【发布时间】:2018-08-31 10:58:17
【问题描述】:
当使用包含 Electron 应用程序的谷歌地图应用程序时,我面临来自谷歌的 RefererNotAllowedMapError 错误,这意味着当前应用程序 url 无法使用当前 APIKey 对谷歌地图进行请求。 从理论上讲,我们可以将应用程序域列入白名单或在 google 面板中设置通配符(我想省略)。
我尝试了多种方法:
- 在 google 地图面板中允许来自 file:/// 的请求,但 google 说“file:///”不正确。问题是电子中的路径有 3 个斜线
- 使用插件设置推荐人 (https://github.com/akameco/electron-referer) - 运气不好
-
使用设置引荐来源网址
Object.defineProperty(document, "referrer", {get : function(){ return "mydomain.com"; }}); -
在 loadUrl 中设置引荐来源 - 运气不好
mainWindow.loadURL(url.format({ pathname: 'index.html', protocol: 'file:', slashes: true }), { httpReferrer: 'mydomain.com', })
还有其他方法可以解决这个问题吗?
【问题讨论】:
-
运行应用程序时
window.location.href的确切值是多少? -
@xomena 这是文件:///web/#/
标签: google-maps google-maps-api-3 electron