如何通过HTTPS获取angular-cli到ng [英] How to get angular-cli to ng serve over HTTPS
本文介绍了如何通过HTTPS获取angular-cli到ng的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下似乎没有做任何事情。
The following doesn't seem to do anything.
ng serve --ssl true --ssl-key <key-path> --ssl-cert <cert-path>
通过提供证书和密钥来创建证书和密钥默认的ssl目录仍然无效。看起来ng服务器完全忽略了ssl参数并继续说 NG Live Development Server正在http:// localhost:4200上运行。
推荐答案
如上一条评论中所述,Angular-CLI现在可以使用SSL选项。如您所知,您可以手动选择要使用的命令和证书:
As stated in a previous comment, Angular-CLI now works with the SSL options. Like you've noted, you can manually select which key and cert you'd like to use with the command:
ng serve --ssl --ssl-key <key-path> --ssl-cert <cert-path>
如果你想设置密钥和证书的默认路径,那么你可以进入你的.angular-cli.json文件相应地调整默认值部分:
If you'd like to set a default path for your key and cert then you can go into your .angular-cli.json file adjust the Defaults section accordingly:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
...
"defaults": {
...
"serve": {
"sslKey": "<relative path from .angular-cli.json>/server.key",
"sslCert": "<relative path from .angular-cli.json>/server.crt"
},
...
},
...
}
然后你可以运行:
ng serve --ssl
这篇关于如何通过HTTPS获取angular-cli到ng的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文