Skip to content

Instantly share code, notes, and snippets.

@slmyers
Created August 30, 2018 01:16
Show Gist options
  • Save slmyers/87f3788216bab36a288c65fb5941a675 to your computer and use it in GitHub Desktop.
Save slmyers/87f3788216bab36a288c65fb5941a675 to your computer and use it in GitHub Desktop.
Example of running https server with node.
const http = require('http');
const https = require('https');
const fs = require('fs');
const App = require('./App');
const httpsOpts = {
key: fs.readFileSync("../certs/key.pem", "utf8"),
cert: fs.readFileSync("../certs/server.crt", "utf8")
};
http.createServer(App).listen(3000, () => console.log("The http server is listening on port 3000."));
https.createServer(httpsOpts, App).listen(3001, () => console.log("The https server is listening on port 3001."));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment