1. Start powershell as administrator
2. choco install mkcert
3. create a _cert folder in node js app root directory
4. mkcert -install
5. mkcert -pkcs12 localhost
This will create 2 files localhost.pem, localhost-key.pem
6. in server.js make following code change
const https = require('https');
const fs = require('fs');
const options = {
key: fs.readFileSync(__dirname + '/_certs/localhost-key.pem'),
cert: fs.readFileSync(__dirname + '/_certs/localhost.pem'),
};
let PORT = process.env.PORT || 5000;
https.createServer(options, app).listen(`${PORT}`, () => {
console.log('Server listening on port ' + `${PORT}`);
});
No comments:
Post a Comment