Created
August 30, 2018 01:16
-
-
Save slmyers/87f3788216bab36a288c65fb5941a675 to your computer and use it in GitHub Desktop.
Example of running https server with node.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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