【问题标题】:Run Angular Cli Ng Serve over https 2018通过 https 2018 运行 Angular Cli Ng Serve
【发布时间】:2018-04-24 06:35:24
【问题描述】:

有没有办法可以通过 https 运行我的 Angular 本地主机?我尝试了一些不同的教程,但没有任何工作我试过.. serve your angular cli app over https 但它仍然可以通过 http:// 服务有没有人成功地做到了这一点?如果是这样,你能指出我正确的方向吗?

谢谢

【问题讨论】:

  • @PardeepJain 必须有一种方法可以通过 https 运行开发 Angular 应用程序
  • 您最好的选择是运行带有证书的服务器。您可以查看let's encrypt 了解如何创建服务器。然后,您应该能够通过 https 访问您的应用程序。

标签: angular https


【解决方案1】:

另一种选择,如果您没有证书并且想使用自签名进行测试,只需在 package.json 中添加标志 "start": "ng serve --ssl",,它会在为应用程序提供服务时生成一个。

Angular CLI: 7.3.1
Node: 8.11.3
OS: win32 x64
Angular: 7.2.5

命令:

npm start

输出:

> ng serve --ssl
** Angular Live Development Server is listening on localhost:4200, 
open your browser on https://localhost:4200/ 
     10% building 4/4 modules 0 activei 「wds」: Generating SSL Certificate

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-22
    • 1970-01-01
    • 1970-01-01
    • 2020-04-19
    • 2017-12-08
    • 2018-02-07
    • 2019-06-23
    • 1970-01-01
    相关资源
    最近更新 更多