-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
26 lines (20 loc) · 722 Bytes
/
server.js
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
var http = require("http");
var https = require("https");
var fs = require("fs");
var express = require('express');
var app = express();
app.use(express.static(__dirname+ "/src"));
app.set('port', (process.env.PORT || 80));
var sslOptions = {
key: fs.readFileSync('https-requirements/localhost.key'),
cert: fs.readFileSync('https-requirements/localhost.crt'),
ca: fs.readFileSync('https-requirements/ca.crt'),
requestCert: true,
rejectUnauthorized: false
};
var httpServer = http.createServer(app);
var httpsServer = https.createServer(sslOptions, app);
var httpsPort = 443;
console.log("starting on " + httpsPort + ' (https)');
httpServer.listen(app.get('port'));
httpsServer.listen(httpsPort);