-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
32 lines (28 loc) · 895 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
27
28
29
30
31
32
(function() {
var http = require('http'),
express = require('express'),
app = express(),
port = process.env.PORT || 80,
ip = process.env.IP || '0.0.0.0';
// Simple logger.
app.use(function(req, res, next) {
console.log('%s %s', req.method, req.url);
next();
});
// Set generic headers used in all responses.
app.use(function(req, res, next) {
res.set({
'X-Powered-By': 'NodeJS',
'Access-Control-Allow-Methods': 'GET, POST', // Allowed request http verbs.
'Access-Control-Allow-Headers': 'X-Requested-With,content-type' // Allowed request headers.
});
next();
});
// Handle all static file GET requests.
app.use(express.static(__dirname + '/build'));
http.createServer(
app.handle.bind(app)
).listen(port, ip, function() {
console.log('Listening on http://' + ip + ':' + port);
});
} ());