Skip to content

Instantly share code, notes, and snippets.

@jfsiii
Created July 14, 2012 19:06
Show Gist options
  • Save jfsiii/3112758 to your computer and use it in GitHub Desktop.
Save jfsiii/3112758 to your computer and use it in GitHub Desktop.
Requests come into publicPort and are sent to apiPort or handlebarPort
var http = require('http'),
httpProxy = require('http-proxy'),
publicPort = 8000,
handlebarPort = 8080,
apiPort = 8888
httpProxy.createServer(function (req, res, proxy) {
if (req.url.match(/\.json$/)) {
proxy.proxyRequest(req, res, {
host: 'localhost',
port: apiPort
});
}
else {
proxy.proxyRequest(req, res, {
host: 'localhost',
port: handlebarPort
});
}
}).listen(publicPort);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment