【发布时间】:2018-01-16 09:37:43
【问题描述】:
我的应用成功地集成了 Google Maps JS API/Google Places API Web Service 以创建一些Autocomplete 下拉菜单。我设置了我的 google api 浏览器密钥,以便开发(本地主机)、登台和生产 url 工作。但是,在使用此服务的任何页面上,验收测试(使用 127.0.0.1)都会中断。例如:
Capybara::Poltergeist::JavascriptError:
One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).
Google Maps API error: RefererNotAllowedMapError https://developers.google.com/maps/documentation/javascript/error-messages#referer-not-allowed-map-error
Your site URL to be authorized: http://127.0.0.1:52724/clients/3
Google Maps API error: RefererNotAllowedMapError https://developers.google.com/maps/documentation/javascript/error-messages#referer-not-allowed-map-error
Your site URL to be authorized: http://127.0.0.1:52724/clients/3
at https://maps.googleapis.com/maps/api/js?v=3.exp&key=(my_browser_key)&signed_in=true&libraries=places:34 in hb
我尝试将不同的 127.0.0.1 配置添加到我的浏览器密钥凭据中,但没有成功,例如:
http://127.0.0.1:* , */127* , and */127.0.0.1:\d\d\d\d\d/*
最后一个看起来很有趣,因为我的测试套件的每次新运行都会在 127.0.0.1: 之后生成 5 个随机数字,如上面的错误所示。
*我不想通过更改错误中提到的 poltergeist 配置来忽略 JS 错误。话虽如此,我实际上并没有在任何这些验收测试中使用该服务。我不想测试 google 功能,我想测试围绕这些下拉菜单的自定义功能。
【问题讨论】:
-
这个应用在前端使用 Angular 1,在后端使用 Rails 4。如果由于某种原因其中任何一个是相关的。
标签: google-maps google-maps-api-3 capybara poltergeist