我在 SO 上查看了此链接:Dealing with HTTP content in HTTPS pages
我从这里尝试了关于开放协议(protocol)的这个:http://benpowell.org/https-and-http-the-protocol-less-or-protocol-relative-urls/
但是我只有一次调用 openweathermap 的 HTTP url,它不通过 HTTPS 提供它的内容,除非你付给他们 500/mo。做不到。
因此,我需要找到一种方法来引入 OpenWeatherMap 的 HTTP 内容,而不是在“任何”浏览器上生成“混合内容”错误消息。
这是 OWM 的 API 调用:http://api.openweathermap.org/data/2.5/weather?lat=32.22&lon=-100.50&APPID=c6fdcf2d49a0bba3e14f310bd3d5cdc2
任何想法,任何人?
提前致谢。
最佳答案
在尝试使用 Open Weather Map API 将我的应用程序托管在 heroku 上时偶然发现了这个线程。
把这个放在网址前面:
这样url就变成了
https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/forecast? appid=${API_KEY}
再次检查您的应用程序,注意 openweather url 又是 http(原来的方式)!这个解决方案对我有用,尽管 CORS 解决方案可能不会永远持续下去。
关于http - 使用仅通过 HTTPS 网站使用 HTTP 的 Open Weather Map,并且不会收到混合内容警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24845531/