-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (23 loc) · 744 Bytes
/
server.js
File metadata and controls
28 lines (23 loc) · 744 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
28
var express = require('express');
var app = module.exports = express();
var proxy = require('http-proxy').createProxyServer({
host: 'http://localhost:8000'
});
app.use('/api', function(req, res, next) {
var data = "";
req.on('data', function(chunk) {data += chunk});
req.on('end', function() {
if (req.path.indexOf('messaging') > -1) {
console.log(req.method + '\t\t' + req.path + '\t\t' + data);
} else {
console.log(req.method + '\t\t' + req.path + '\t\t\t' + data);
}
});
proxy.web(req, res, {
target: 'http://localhost:8000/api'
}, next);
});
app.use(express.static(__dirname + '/public'));
app.listen(80, function () {
console.log('----SERVER STARTED---- ' + new Date().toISOString());
});