Skip to content

Instantly share code, notes, and snippets.

@ptantiku
Created April 30, 2018 17:30
Show Gist options
  • Save ptantiku/370a26c01b41f4f469d2c3945c3f28ce to your computer and use it in GitHub Desktop.
Save ptantiku/370a26c01b41f4f469d2c3945c3f28ce to your computer and use it in GitHub Desktop.
Append code to app.js for enable HTTP or HTTPS
// start the server HTTP & HTTPS
const http = require('http');
const https = require('https');
const fs = require('fs');
var credentials = {
key: fs.readFileSync('./ssl-cert.key'),
cert: fs.readFileSync('./ssl-cert.cert')
};
// use HTTP
// http.createServer(app).listen(80);
// use HTTPS
https.createServer(credentials , app).listen(443);
console.log("Express is running ...");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment