简体   繁体   English

每次运行 Angular 时,SSL 都会出现问题,这是为什么?

[英]Everytime I run Angular I have a problem with the SSL why is that?

In the past when I run Angular projects on my pc it was straight forward, but now every project I run give this kind of errors:过去,当我在我的电脑上运行 Angular 项目时,它很简单,但现在我运行的每个项目都会出现这种错误:

在此处输入图像描述

I know is the think is the lack of SSL certificate, but since I remember I've never had to add the SSL certificate to my projects in the past, and they don't mention it in the Angular tutorials, what happen is because the versions of Angular or maybe I change something in my pc and now I have to add it to every project I create?我知道是认为缺少 SSL 证书,但自从我记得过去我从来没有将 SSL 证书添加到我的项目中,并且他们在 Angular 教程中没有提到它,发生的事情是因为Angular 的版本或者也许我更改了我的电脑中的某些内容,现在我必须将它添加到我创建的每个项目中?

This might be a duplicate of ERR_SSL_PROTOCOL_ERROR not able to see https localhost pages in chrome browser .这可能是ERR_SSL_PROTOCOL_ERROR not able to see https localhost pages in chrome browser的副本。

But here you have two quick steps to validate:但是在这里你有两个快速的步骤来验证:

  1. are you using HTTPS in the url?您在 url 中使用 HTTPS 吗? Is your url looking something like this: https://localhost:4200?您的 url 看起来像这样吗:https://localhost:4200? If yes, change https with simple http and try again.如果是,请将 https 更改为简单的 http,然后重试。

  2. if point no.如果没有。 1 didn't help because you were already on http, try clearing all the data of the http://localhost:4200 (or the port you're using), including cache, local storage, session storage etc. This should do the trick (it did in my case). 1 没有帮助,因为你已经在 http 上,尝试清除 http://localhost:4200(或你正在使用的端口)的所有数据,包括缓存、本地存储、session 存储等。这应该做把戏(在我的例子中确实如此)。

  3. if you're on Windows, make sure that you don't have any aliases for localhost or 127.0.0.1 inside of the 'hosts' file (found at "C:\Windows\System32\drivers\etc\hosts").如果您使用的是 Windows,请确保您在“主机”文件(位于“C:\Windows\System32\drivers\etc\hosts”)中没有本地主机或 127.0.0.1 的任何别名。

Hope either of these will help you.希望其中任何一个对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM