-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathserver.prod.js
35 lines (31 loc) · 899 Bytes
/
server.prod.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
27
28
29
30
31
32
33
34
35
var fs = require('fs');
var http = require('http');
var https = require('https');
var path = require('path');
var express = require('express');
var app = express();
app.set('port', (process.env.PORT || 8080));
app.use(function(req, res, next) {
if (path.extname(req.path).length > 0) {
next();
} else if (path.dirname(req.path).indexOf('silent_renew') > -1) {
req.url = '/silent_renew.html';
next();
} else {
req.url = '/index.html';
next();
}
});
app.use(express.static(__dirname + '/dist'))
.get('/', function (req, res) {
res.sendFile('index.html', {
root: __dirname + '/dist'
});
}).get('/silent_renew.html', function(req, res) {
res.sendFile('silent_renew.html', {
root: __dirname + '/dist'
});
});
app.listen(app.get('port'), function() {
console.log('Listening on port', app.get('port'));
});