Serving Your Angular CLI Apps Locally Over HTTPS
When running an Angular CLI app locally, it's easy to set it up to run over HTTPS to more accurately match how it would run in a secure production environment (rather than just running it over HTTP locally). The below approach works with Angular CLI 6 and above, but may also be available in earlier versions.
In your angular.json file, look for your project in the projects node and then find the serve child node. Under that node, you can add a property called ssl and set the value to true to cause Angular CLI to build the project with a local SSL cert that it will create for you.
When you run ng serve for the first time after adding this property, there will be some output on the command line regarding the certificate being created. After awhile, it will also remove and regenerate certificates as they expire. And they made it pretty easy to set up!
In your angular.json file, look for your project in the projects node and then find the serve child node. Under that node, you can add a property called ssl and set the value to true to cause Angular CLI to build the project with a local SSL cert that it will create for you.
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "staff-portal-two:build",
"ssl": true
},
When you run ng serve for the first time after adding this property, there will be some output on the command line regarding the certificate being created. After awhile, it will also remove and regenerate certificates as they expire. And they made it pretty easy to set up!
Comments
Post a Comment