Unable to use navigator.geolocation due to 'Only secure origins are allowed'

前提是你 提交于 2021-02-08 15:12:12

问题


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() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS.


回答1:


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)



来源:https://stackoverflow.com/questions/36858628/unable-to-use-navigator-geolocation-due-to-only-secure-origins-are-allowed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!