block by ThomasG77 acf9ffd02220f0555f9e034c7c220aa9

Use https certificate on localhost with Express

Use https certificate on localhost with Express

Note: tested on Ubuntu

Install utilities

sudo apt install libnss3-tools
wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.3/mkcert-v1.4.3-linux-amd64
chmod +x mkcert-v1.4.3-linux-amd64 
sudo mv mkcert-v1.4.3-linux-amd64 /usr/local/bin/mkcert

Create certificate for your app

# If you do not want to install certifictaes to your browsers
# mkcert -install localhost
# If you want to make trusted certificates to your browsers
# If you have a firefox master password, you should enter it
# when you see "Enter Password or Pin for "NSS Certificate DB""
mkcert -install localhost

Install an run the app

npm i
node app.js

Then, go to https://localhost:3001/

app.js

package.json