I'm trying to start the server in HTTPS using Express 4.x. I tried
var credentials = {key: privateKey, cert: certificate};
var app = express(credentials);
But it's not working.
To start your https server, run node app. js (here, app. js is name of the file) on the terminal. or in your browser, by going to https://localhost:8000 .
There's really no reason to create your own http server using the http module. Express will just do that for you with app. listen() just fine and save you little bit of typing. If you were creating an https server, then you would need to use the https module and pass security credentials to https.
You could easily just do something like this:
var app = express(),
credentials = {key: privateKey, cert: certificate},
server = https.createServer(credentials, app);
server.listen(8443);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With