google浏览器跨域问题的一种可能性

莫名奇妙突然发生的跨域问题

关于跨域的配置,其实无论是nginx还是后台服务器,我们本来都已经配置好了。但在使用过程中,本来1个小时前还一切都好好的,突然怎么跨域问题又出现了呢?经过一系列调研,发现是google浏览器在“搞鬼”。

chrome的HSTS

chrome有一个hsts功能,它会对你访问过的域名做智能的安全登记。如果那边的域名支持https协议,那么等下次你再访问同一个域名时,它就会给你自动将http转化为https请求。在我们实际测试环境中,使用的是http://test.example.com。但如果我访问了https://www.example.com之后,chrome浏览器就会默认的把后面对http://xxx.example.com访问的请求都自动改为https://xxx.example.com了。

解决方案

  1. 打开这个页面 chrome://net-internals/#hsts
  2. 在  "Delete domain security policies" 的项目里,添加example.com, 然后点击“Delete”

参考文献

https://howchoo.com/chrome/stop-chrome-from-automatically-redirecting-https

发表评论

邮箱地址不会被公开。 必填项已用*标注