无法使用 navigator.geolocation 由于'只允许安全来源' [英] Unable to use navigator.geolocation due to 'Only secure origins are allowed'

查看:33
本文介绍了无法使用 navigator.geolocation 由于'只允许安全来源'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我使用 navigator.geolocation.getCurrentPosition(如下)创建我的网站以来,控制台中出现错误.我意识到这会在未来的某个时候引起问题,因为我只是在玩网络开发,所以我并没有那么担心,但它现在已经完全搞砸了我的小天气应用程序(http://conn3cted.uk.tn/weather.html) 因为我好像不能用这个chrome 中的功能(它在 Firefox 中工作)了.我现在另外得到的错误是 只允许安全来源. 我能做些什么来解决这个问题吗?我真的不想无缘无故地花钱获得 HTTPS 证书.

There has been an error, in the console, since I made my website using navigator.geolocation.getCurrentPosition (below). I realised this was going to cause a problem at some point in the future, and as I'm only playing with web development it didn't concern me that much, but it has now completely screwed up my little weather app (http://conn3cted.uk.tn/weather.html) as it seems that I can't use this function in chrome (it works in firefox) anymore. The error I'm getting additionally now is Only secure origins are allowed. Is there anything I can do to get around this? I don't really want to pay to get a HTTPS certificate for no reason.

<代码>getCurrentPosition() 和 watchPosition() 在不安全的来源上被弃用.要使用此功能,您应该考虑将应用程序切换到安全来源,例如 HTTPS.

推荐答案

此类内容只推荐使用 https.我鼓励您将您的网站迁移到 HTTPS,也许使用让我们加密(免费证书)

Only https is recommanded for this kind of stuff. I encourage you to to migrate your website to HTTPS, maybe using let's encrypt (free certificate)

这篇关于无法使用 navigator.geolocation 由于&amp;#39;只允许安全来源&amp;#39;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆