Sometimes you want to test your application in environment closer to the real world. In such cases you might need to run it over TLS.
Here are two simple steps, which can be used to achieve this result:
Generate self-signed certificate
If you don’t already have certificate you need to generate one:
You will be asked a couple of questions…
In this case we generated a self-signed certificate for 365 days.
Use Express with HTTPS
This script will create Express application running over HTTPs.
Run the application:
Enter the passphrase you entered during the creation of the certificate…
Now open your browser: https://localhost:55555/.
After trusting the certificate you’d be done!
PS: Note that you may get error like:
In this case you need to remove the pass: