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.

"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

Popular Posts

Resolving the "n timer(s) still in the queue" Error In Angular Unit Tests

Silent Renew and the "login_required" Error When Using oidc-client

How to Get Norton Security Suite Firewall to Allow Remote Desktop Connections in Windows

Fixing the "Please add a @Pipe/@Directive/@Component annotation" Error In An Angular App After Upgrading to webpack 4

How to Determine if a Column Exists in a DataReader