How to create an https server? | Node.js

PHOTO EMBED

Fri Jul 09 2021 05:09:26 GMT+0000 (Coordinated Universal Time)

Saved by @stewardjornsen #javascript

const https = require('https');
const fs = require('fs');

const options = {
  key: fs.readFileSync('key.pem'),
  cert: fs.readFileSync('cert.pem')
};

https.createServer(options, function (req, res) {
  res.writeHead(200);
  res.end("hello world\n");
}).listen(8000);
content_copyCOPY

https://nodejs.org/en/knowledge/HTTP/servers/how-to-create-a-HTTPS-server/