【问题标题】:HERE geocoder-autocomplete with ReactJS suddenly returning Network Error on Firefox使用 ReactJS 的 HERE geocoder-autocomplete 在 Firefox 上突然返回网络错误
【发布时间】:2020-01-06 22:47:18
【问题描述】:

我已经实现了HERE tutorial 的解决方案,它在 Firefox 和 chrome 上运行良好。然而,几周前它停止了在 Firefox 上的工作并开始返回 Network Error。该请求甚至没有显示在我的网络日志中。

我已经使用我的凭据测试了API EndPoint,它确实有效。它也适用于谷歌浏览器。

我尝试通过 .env 对凭据进行硬编码,但两种方法都不适用于 firefox

我的代码:

try {
  const address = await axios.get(`https://autocomplete.geocoder.api.here.com/6.2/suggest.json`,{
    params: {
      app_id: APP_ID_HERE,
      app_code: APP_CODE_HERE,
      query,
      maxresults: 1,
      country: 'AUS',
      state: 'Western Australia'
    }
  });    
  console.log('address:',address);
} catch (error) {
  console.log('address-error:',error);
}

依赖关系:

"dependencies": {
  "axios": "^0.19.0",
  "react": "^16.8.6",
}

HERE 是否对此 API 进行了任何更改?

我也提出了 Axios 的问题 -> https://github.com/axios/axios/issues/2388

谢谢

【问题讨论】:

  • API 没有任何变化,如果可以共享您收到的响应将会很有帮助.. 任何响应代码或错误
  • @HEREDeveloperSupport 对此有何更新?谢谢
  • 这表示身份验证错误:401 - 验证 app_id/app_code 对失败。 app_code 与 app_id 不匹配,或者 app_id 无权使用 Geocoder Autocomplete API。
  • @HEREDeveloperSupport,这没有任何意义,因为它适用于 Chrome,但不适用于 Firefox!!!
  • @HEREDeveloper,我发现了问题:Firefox 阻止了一些资产,atm 一个新的 react-app 给出了这个错误:Unhandled Rejection (SecurityError): The operation is insecure. 但它在private window 上正确运行,API 也适用于它。但我不确定如何解决它....

标签: reactjs axios here-api here-autocomplete


【解决方案1】:

这更多与 firefox web-socket 安全问题有关,解决方法请参考Firefox Websocket security issue,如果您仍有问题,请告诉我们。

应用程序本身在 SSL 下,但正在访问的 websocket 不是。 Chrome 和 Opera 不在乎,但 Firefox 不在乎。根据:

https://bugzilla.mozilla.org/show_bug.cgi?id=303952

这是已知的,不被视为错误。 Mozilla 的回应:不会修复

Solution, put websocket server under SSL and use wss://

【讨论】:

    猜你喜欢
    • 2019-10-30
    • 2018-09-23
    • 2021-08-17
    • 1970-01-01
    • 2019-08-09
    • 1970-01-01
    • 2015-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多