Reputation: 509
I am developing a website which require the use of the navigator.geolocation object through a local development environment on MACOSX. I am using Chrome 53. Considering geolocation is blocked on anything that isn't HTTPS how am I suppose to develop my website locally? The Google Developers site quotes:
Does this affect local development?
It should not, localhost has been declared as "potentially secure" in the spec and in our case geolocation requests served at the top level over localhost will still work.
Here's what I am seeing:
Any ideas? (aside from switch browser)
Upvotes: 7
Views: 4595
Reputation: 1456
http://localhost
is treated as a secure origin, so you don't need to do anything, the Geolocation will work.
If you're using another hostname that points to the localhost (Ex: http://mysite.test
) then you should run chrome from the command line with the following option: --unsafely-treat-insecure-origin-as-secure="http://mysite.test"
.
Example
google-chrome --unsafely-treat-insecure-origin-as-secure="http://yoursite.test"
More details on Deprecating Powerful Features on Insecure Origins
Upvotes: 9
Reputation: 509
The answer to this question is to set VirtualHost in XAMPP to use the SSL Engine. This question has already been answered here: How do I use https (SSL) in XAMPP while using virtual hosts
This then allows the Geolocation to run through HTTPS on a local development environment using XAMPP.
Upvotes: 0
Reputation: 1
Use file:
protocol. Launch chrome with --allow-file-access-from-files
flag set, see Jquery load() only working in firefox?. At Settings
select Content settings
, scroll to Location
, select Ask when a site tries to track your physical location (recommended)
.
Upvotes: 0