Created
July 14, 2012 19:06
-
-
Save jfsiii/3112758 to your computer and use it in GitHub Desktop.
Requests come into publicPort and are sent to apiPort or handlebarPort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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