Skip to content

Instantly share code, notes, and snippets.

@Overdrivr
Last active Nov 8, 2016
Embed
What would you like to do?
HTTPS static file server with connect
var connect = require('connect');
var serveStatic = require('serve-static');
var https = require('https');
// Get certificates for free here
// https://letsencrypt.org/
var key = fs.readFileSync('./key.pem');
var cert = fs.readFileSync('./cert.pem')
var options = {
key: key,
cert: cert
};
var port = 443;
var folder = __dirname;
var app = connect();
app.use(serveStatic(folder));
https.createServer(options, app).listen(port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment