Fix the following error when trying to run local server using https
:
Install mkcert
and generate key and cert
# Install mkcert
brew install mkcert
# Create local CA (certificate authority)
mkcert -install
# Generate key and certificate for localhost
mkcert localhost
Pass an object with key
and cert
when creating new server using https
:
const options = {
key: '<YOUR_KEY>',
cert: '<YOUR_CERT>',
}
https.createServer(options, (req, res) => { ... })