问题
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