Generate SSL by mkcert
mkcert example.com "*.example.com" example.test localhost 127.0.0.1 ::1
const key = fs.readFileSync("./ssl/localhost-key.pem");
const cert = fs.readFileSync("./ssl/localhost.pem");
const app = express();
const secureServer = https.createServer({ key: key, cert: cert }, app);
app.get("/", (req, res) => {
res.send("Hello world!");
});
secureServer.listen(3000, "localhost", (err) => {
if (err) throw err;
console.log(`> Live @ https://localhost:3000`);
});