Skip to content

Commit

Permalink
fixed and updated server.js
Browse files Browse the repository at this point in the history
  • Loading branch information
zuk committed Mar 16, 2014
1 parent 2931095 commit 25d074c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -4,8 +4,8 @@
"description": "Mobile website for VEOS",
"author": "Matt Zukowski, Colin McCann, Armin Krauss",
"dependencies": {
"http-proxy": ">= 0.7.6",
"node-static": ">= 0.5.9"
"http-proxy": "~1.0.2",
"node-static": "~0.7.3"
},
"engine": "node 0.8.2"
}
46 changes: 23 additions & 23 deletions server.js
Expand Up @@ -12,25 +12,26 @@ var url = require('url');
var util = require('util');
var fs = require('fs');


var proxy = new httpProxy.RoutingProxy();
var file = new(httpStatic.Server)('.', {
cache: 0,
headers: {
"Pragma-directive": "no-cache",
"Cache-directive": "no-cache",
"Cache-control": "no-cache",
"Pragma": "no-cache",
"Expires": "0"
}
});
var proxy = httpProxy.createProxyServer({});
//
// var file = new(httpStatic.Server)('.', {
// cache: 0,
// headers: {
// "Pragma-directive": "no-cache",
// "Cache-directive": "no-cache",
// "Cache-control": "no-cache",
// "Pragma": "no-cache",
// "Expires": "0"
// }
// });
var file = new httpStatic.Server('.');


var server = http.createServer(function (req, res) {
var i;
for (i = 0; i <= server.proxyMap.length; i++) {
var map = server.proxyMap[i];

if (map.match(req)) {
map.proxy(req, res);
break;
Expand Down Expand Up @@ -59,36 +60,35 @@ server.proxyMap = [
req.headers['host'] = veosURL.hostname;
req.url = url.parse(req.url).path.replace(/^\/backend/,'');
//console.log(req);
proxy.proxyRequest(req, res, {
host: veosURL.hostname,
port: veosURL.port || 80
proxy.web(req, res, {
target: "http://"+veosURL.hostname+":"+(veosURL.port||80)
});
}
},

{
{
name: "home STATIC",
match: function(req) {
match: function(req) {
var reqPath = url.parse(req.url).pathname;
return reqPath === '/' || reqPath === '';
},
proxy: function(req, res) {
req.addListener('end', function() {
req.url = "/app.html";
console.log("home STATIC "+req.url);
file.serve(req, res);
});
file.serve(req, res);
}).resume();
}
},

{
name: "STATIC",
match: function(req) { return true; },
proxy: function(req, res) {
req.addListener('end', function(){
req.addListener('end', function(){
console.log("STATIC "+req.url);
file.serve(req, res);
});
file.serve(req, res);
}).resume();
}
}
];
Expand Down

0 comments on commit 25d074c

Please sign in to comment.