Safari Localhost Permission Blocked

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 05:04:05

问题


So ran into this issue today, where I have a website that needs the geolocation of the user. It was working fine when running locally on localhost, but now I get an error saying "Access to geolocation was blocked over insecure connection to http://localhost:4200". WTF Apple? I also tried 127.0.0.1 but got the same result. Am I missing something in the dev settings or did Apple just break everything?

Safari Version: 9.1.3 (11601.7.8)


回答1:


Maybe it's possible to use https ( How to get angular-cli to ng serve over HTTPS ) and if not is possible directly for some reason maybe you can use a transparent proxy that offers https.

Many HTML5 new features like access to webcam, geolocation and others are now allowed only on pages served thru https scheme, so probably using https will work again. If not, maybe is possible to modify hosts file to workaround the problem.




回答2:


I found a sort of solution but it is a bit tedious. I use ngrok to route my server and then the geolocation works fine. The only thing I don't like is that it has limits (if you are using free account), like you can't refresh a lot of times.

edit:

To Use ngrok download it first, then on terminal type

./ngrok http <port number>

ngrok example. It will then show you the url routes. I used https. Go to to that address.

More ngrok instructions and download



来源:https://stackoverflow.com/questions/39797559/safari-localhost-permission-blocked

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