Node.js and Express with HTTPS

Quoting from the doco + some missing stuff:

var express = require('express');
var https = require('https');
var http = require('http');
var app = express();
var fs = require('fs');

var options = {
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
};

http.createServer(app).listen(80);
https.createServer(options, app).listen(443);

nJoy 😉

Leave a Reply

Your email address will not be published. Required fields are marked *