-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathweb-server.js
More file actions
23 lines (18 loc) · 810 Bytes
/
web-server.js
File metadata and controls
23 lines (18 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var express = require('express');
var enforce = require('express-sslify');
var app = express();
var options = {};
// On Heroku web dynos must bind to the port defined by the env variable 'PORT'.
app.set('port', (process.env.PORT || 5000));
if (process.env.NODE_ENV === 'production') {
// Redirect HTTP to HTTPS (uses Heroku's x-forwarded-proto header).
app.use(enforce.HTTPS({ trustProtoHeader: true }));
// Give all files a Cache-Control max-age of 15 minutes.
// Intentionally not enabled during development.
options = { maxAge: '15m' };
}
// Serve the bugherder subdirectory using the express.static middleware.
app.use(express.static(__dirname + '/bugherder', options));
app.listen(app.get('port'), function() {
console.log("Server is running at http://localhost:" + app.get('port'));
});