30

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)

trev9065
  • 3,371
  • 4
  • 30
  • 45
  • 3
    Have this issue too with Ionic development. Safari seems to block even localhost where Chrome allows geolocation permissions on localhost. Unhelpful if your development is Safari browser of choice. – Ian Tearle Oct 13 '16 at 09:41
  • Yeah, this is definitely a Safari bug, it just makes testing this stuff that much harder. – trev9065 Oct 13 '16 at 15:01
  • Having the same issue, was a solution ever found? – halfacreyum Nov 11 '16 at 01:07
  • 2
    No, there is no solution at the moment. – trev9065 Nov 14 '16 at 20:51
  • 1
    More than a year later: are we still in the dark? I can bypass ATS on localhost with a property but absolutely cannot get Geolocation API to work. – Heits Jan 30 '18 at 22:37

2 Answers2

2

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.

user1039663
  • 1,230
  • 1
  • 9
  • 15
0

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

  • 2
    (As reviewer), I'm pretty familiar with most of the technologies in the question's problem description, but I'm not clear on how I'd put your answer to work. Can you give it a little more backstory? TIA. – benc Nov 11 '18 at 22:45