Google Chrome将localhost重定向到https

本文翻译自:Google Chrome redirecting localhost to https

When I debug a Visual Studio project using Chrome the browser tries to redirect to the https equivalent of my web address. 当我使用Chrome调试Visual Studio项目时,浏览器会尝试重定向到等效于我的网址的https。 I do not have SSL enabled in the web project and the start URL is the http URL. 我没有在Web项目中启用SSL,并且起始URL是http URL。 When I debug using FireFox or IE I do not have this problem. 当我使用FireFox或IE进行调试时,我没有此问题。

I did re-install Chrome which fixed the problem for a day. 我确实重新安装了Chrome,从而解决了一天的问题。 Without downloading any addons the problem happened again the next day. 没有下载任何插件,第二天又发生了问题。

What is making Chrome redirect localhost to https? 是什么让Chrome将localhost重定向到https?

Network Inspect Shows: Request URL:data:text/html,chromewebdata Request Headers Provisional headers are shown User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36 网络检查显示:请求URL:data:text / html,chromewebdata请求标头显示临时标头User-Agent:Mozilla / 5.0(Windows NT 6.3; WOW64)AppleWebKit / 537.36(KHTML,如Gecko)Chrome / 36.0.1985.143 Safari / 537.36

No preview and no response data in those tabs. 这些标签中没有预览,也没有响应数据。


#1楼

参考:https://stackoom.com/question/1i3ov/Google-Chrome将localhost重定向到https


#2楼

I never figured out the root of the problem however I was able to fix this problem. 我从未弄清楚问题的根源,但是我能够解决此问题。 I deleted the Google Chrome app cache folder which solved the problem. 我删除了Google Chrome应用程序缓存文件夹,此问题已解决。

C:\\Users[users]\\AppData\\Local\\Google\\Chrome C:\\ Users [用户] \\ AppData \\ Local \\ Google \\ Chrome


#3楼

I believe this is caused by HSTS - see http://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security 我相信这是由HSTS引起的-请参阅http://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security

If you have (developed) any other localhost sites which send a HSTS header... 如果您有(开发过)其他任何发送HSTS标头的本地主机站点...

eg. 例如。 Strict-Transport-Security: max-age=31536000; 严格的运输安全性:max-age = 31536000; includeSubDomains; includeSubDomains; preload 预载

...then depending on the value of max-age, future requests to localhost will be required to be served over HTTPS. ...然后根据max-age的值,将来需要通过HTTPS为localhost提供请求。

To get around this, I did the following. 为了解决这个问题,我做了以下工作。

  • In the Chrome address bar type "chrome://net-internals/#hsts" 在Chrome地址栏中,输入“ chrome:// net-internals /#hsts”
  • At the very bottom of a page is QUERY domain textbox - verify that localhost is known to the browser. 页面的最底部是QUERY域文本框-验证浏览器是否知道localhost。 If it says "Not found" then this is not the answer you are looking for. 如果显示“未找到”,则这不是您要查找的答案。
  • If it is, DELETE the localhost domain using the textbox above 如果是这样,请使用上面的文本框删除localhost域
  • Your site should now work using plain old HTTP 您的网站现在应该可以使用普通的旧HTTP了

This is not a permanent solution, but will at least get it working between projects. 这不是一个永久性的解决方案,但至少会使它在项目之间工作。 If anyone knows how to permanently exclude localhost from the HSTS list please let me know :) 如果有人知道如何将本地主机从HSTS列表中永久排除,请告诉我:)

UPDATE - November 2017 更新-2017年11月

Chrome has recently moved this setting to sit under Delete domain security policies Chrome最近已将此设置移至“ 删除域安全策略”下

在此处输入图片说明

UPDATE - December 2017 If you are using .dev domain see other answers below as Chrome (and others) force HTTPS via preloaded HSTS. 更新-2017年12月,如果您使用的是.dev域,请参阅以下其他答案,因为Chrome(及其他)通过预加载的HSTS强制HTTPS。


#4楼

I experienced the same problem in Chrome and I tried unsuccessfully to use BigJump's solution . 我在Chrome中遇到了同样的问题,但尝试使用BigJump的解决方案失败,

I fixed my problem by forcing a hard refresh, as shown in this blog (originally from this SuperUser answer ). 我通过强制硬刷新解决了我的问题,如本博客中所示(最初来自此SuperUser答案 )。

Ensure your address bar is using the http scheme and then go through these steps, possibly a couple of times: 确保您的地址栏正在使用http方案,然后执行以下步骤(可能几次):

  1. Open the Developer Tools panel (CTRL+SHIFT+I) 打开“开发人员工具”面板(CTRL + SHIFT + I)
  2. Click and hold the reload icon / Right click the reload icon. 单击并按住重新加载图标/右键单击重新加载图标。
  3. A menu will open. 将打开一个菜单。
  4. Choose the 3rd option from this menu ("Empty Cache and Hard Reload") 从此菜单中选择第三个选项(“空缓存和硬重载”)

#5楼

I also have been struggling with this issue. 我也一直在努力解决这个问题。 Seems that HSTS is intended for only domain names. 似乎HSTS仅用于域名。 So if you are developing in local machine, it much easier to use IP address. 因此,如果您在本地计算机上进行开发,则使用IP地址要容易得多。 So I switched from localhost to 127.0.0.1 所以我从本地主机切换到127.0.0.1


#6楼

@Adiyat Mubarak answer did not work for me. @Adiyat Mubarak的答案对我不起作用。 When I attempted to clear the cache and hard-reload, the page still redirected to https. 当我尝试清除缓存和硬重装时,页面仍重定向到https。

My solution: In the upper right-hand corner of the url bar (just to the left of the favorites star icon) there is an icon with an "x" through it. 我的解决方案:在网址栏的右上角(在收藏夹星形图标的左侧),有一个带有“ x”的图标。 Right-click on that, and it will say something about "unsafe scripts", then there is an option to load them anyway. 右键单击它,它会说一些有关“不安全脚本”的信息,然后可以选择加载它们。 Do that. 去做。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值