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

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

问题描述

自从我使用 navigator.geolocation.getCurrentPosition (如下所示)创建网站以来,控制台中出现错误.我意识到这会在将来的某个时候引起问题,并且由于我只是在进行Web开发,所以它并没有引起我太多关注,但是现在它已经完全搞砸了我的小天气应用程序( 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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