The easiest method you can find is to install browser-sync as a dev dependency.
npm install browser-sync --save-dev
This will install a self-signed certificate and key for localhost, which you can now point to when adding the --ssl
switches.
Open your package.json in root folder of your angular project and change the start script to the following:
ng serve --ssl true --ssl-key /node_modules/browser-sync/lib/server/certs/server.key --ssl-cert /node_modules/browser-sync/lib/server/certs/server.crt
Now, when you call ng start NPM will run ng serve with the additional SSL switches, and serve your site under HTTPS (e.g. https://localhost:4200).
With all that being said, I highly recommend you keep learning!
Thank you for reading this article. Please feel free to connect with me on LinkedIn and Twitter.
Top comments (0)