-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (19 loc) · 771 Bytes
/
index.js
File metadata and controls
27 lines (19 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var http = require('http')
var https = require('https')
var autoCert = require('anchor-pki/auto-cert').autoCert;
var finalhandler = require('finalhandler')
var serveStatic = require('serve-static')
// Serve up current dir
var serve = serveStatic('./')
var app = function (req, res) {
serve(req, res, finalhandler(req, res))
}
var httpPort = (process.env.HTTP_PORT || 3000)
var httpsPort = process.env.HTTPS_PORT
http.createServer(app).listen(httpPort)
console.log("mixed-content-example app over HTTP: http://localhost:"+httpPort)
// Create HTTPS server if configured
if (httpsPort) {
https.createServer(autoCert(), app).listen(process.env.HTTPS_PORT)
console.log("mixed-content-example app over HTTPS: https://mixed-content-example.lcl.host:"+httpsPort)
}