本地开发Chrome 50+地理位置 [英] Local development of geolocation chrome 50+

查看:68
本文介绍了本地开发Chrome 50+地理位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个网站,要求通过MACOSX上的本地开发环境使用navigator.geolocation对象.我使用的是Chrome53.考虑到地理位置限制在非HTTPS上的任何内容,我应该如何在本地开发我的网站? Google Developers网站引用:

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.

这就是我所看到的:

地理位置控制台警告

有什么想法吗? (除了切换浏览器)

Any ideas? (aside from switch browser)

推荐答案

http://localhost被视为安全来源,因此您无需执行任何操作,地理定位将起作用.

http://localhost is treated as a secure origin, so you don't need to do anything, the Geolocation will work.

如果您使用的另一个主机名指向本地主机(例如:http://mysite.test),则应使用以下选项从命令行运行chrome:--unsafely-treat-insecure-origin-as-secure="http://mysite.test".

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".

示例

google-chrome --unsafely-treat-insecure-origin-as-secure="http://yoursite.test"

有关在不安全的来源上弃用强大的功能

这篇关于本地开发Chrome 50+地理位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆