【问题标题】:Angular 6 angular.json add ssl in configurationAngular 6 angular.json 在配置中添加 ssl
【发布时间】:2018-09-27 14:39:41
【问题描述】:

我想通过 SSL 为我的应用程序提供服务,之前我有这个脚本:

ng serve --ssl --ssl-key "pathtokey\key.crt"

我想在新的 angular.json 中添加 SSL,但是当我尝试添加它时出现错误:

Schema validation failed with the following errors:
 Data path "" should NOT have additional properties(ssl).

在 Angular cli 6 中使用 SSL 的正确方法是什么?

【问题讨论】:

标签: angular typescript angular-cli angular6


【解决方案1】:

ANGULAR 6 要求您定义参数:--ssl-key & --ssl-cert

创建或获取受信任的证书密钥和证书文件并将其放在 C:\certificates\

ng serve --ssl --ssl-key c:\\certificates\\server.key  --ssl-cert c:\\certificates\\server.crt

【讨论】:

    【解决方案2】:

    在 angular.json 中:

    "serve": {
        "builder": "@angular-devkit/build-angular:dev-server",
        "options": {
            "browserTarget": "app:build",
            "ssl": true,
            "sslKey": "path to .key",
            "sslCert": "path to .crt"
        },
        ...
    }
    

    【讨论】:

    • 不错。我在某处读到,如果我们使用 ssl true angular 将为您创建密钥和证书。我在哪里可以看到文件?在哪个目录下?
    猜你喜欢
    • 2018-10-23
    • 2018-10-14
    • 1970-01-01
    • 2018-10-18
    • 2019-01-08
    • 1970-01-01
    • 2019-03-13
    • 2021-08-09
    • 1970-01-01
    相关资源
    最近更新 更多