-1

I want to make my localhost of angular client secure i.e. want to update local url from "http://localhost:4200/" to "https://localhost:"

Any idea how can we do that

NobesInd
  • 77
  • 6
  • If you want to use https in prod only you can use the `import {isDevMode } from '@angular/core'` – Swoox Aug 20 '19 at 07:51

1 Answers1

1

The Angular CLI can serve via HTTPS, but you need to explicitly configure it to do so. First, you need a certificate and key. A self-signed certificate is sufficient for local development and has the advantage that you can put the private key in your project repo, too.

You should create key and certificate with openssl as described here: https://stackoverflow.com/a/10176685/9032927

Next step is to tell Angular CLI to use the certificate and key to serve via HTTPS:

ng serve --ssl --ssl-key path/to/my/ssl.key  --ssl-cert path/to/my/ssl.crt

Please also consult the Angular docs for all possible ng serve options: https://angular.io/cli/serve