首页 > 解决方案 > 使用 ssl 运行角度

问题描述

我想在 localhost ( https://localhost:4200 ) 上使用 ssl 证书运行我的 Angular (7+) 项目。

我从这个链接源尝试了以下内容 - Get angular-cli to ng serve over HTTPS

1)角度.json

{
 "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
 "projects": {
   "<PROJECT-NAME>": {
       "architect": {
           "serve: {
               "options": {
                   "sslKey": "<relative path from angular.json>/server.key",
                   "sslCert": "<relative path from angular.json>/server.crt",
                   ...
               }, ...
             }, ...
         }, ...
     }, ...
 }, ...

}

2)浏览器同步

ng serve --ssl true --ssl-key /node_modules/browser-sync/lib/server/certs/server.key --ssl-cert /node_modules/browser-sync/lib/server/certs/server.crt

当我跑步时:ng serve--ssl我得到这个日志:

** Angular Live Development Server 正在监听 localhost:4200,在https://localhost:4200/上打开浏览器**

在浏览器中

在此处输入图像描述

标签: angularssl

解决方案


推荐阅读