Enable SSL for local development
This document will guide you through the running application on HTTPS mode for local development.
Environment: Mac OS / Unix
This uses the npm package which redirects HTTPS to our HTTP running app. Install the following npm package globally.
Simple SSL HTTP proxy using a self-signed certificate. They are intended for local development only.
npm install -g local-ssl-proxy
After installation use
local-ssl-proxy --source 9001 --target 9000
Here target port is our running application port and source for HTTPS enabled port.
Setup hostname for domain
sudo nano /etc/hosts
- Add the following to let our domain redirect to our local server.
127.0.0.1 xxxproject.local
Run SSL proxy with a self-signed trusted certificate for xxxproject.local
We can use it to hostname xxxproject.local
, and wildcards are also supported.
- Install mkcert (
choco install mkcert
/brew install mkcert
) - Run
mkcert -install
- Run
mkcert xxxproject.local
- Run
local-ssl-proxy --key xxxproject.local-key.pem --cert xxxproject.local.pem --source 9001 --target 9000
We should run our project under port 9000 (target port is our application port) whereas 9001 (SSL enabled port for the application)
You’re all set! Just go to https://xxxproject.local:9001 and see your project working!