How can I serve some URLs from express.js by making requests to another web application?
Problem
I have written some code using express.js which I'd like to put on the same HTTP port as a Web Application implemented with another technology (in this case, Django). I don't want to have to redirect user browsers to another port since if I do they might bookmark URLs with the other port, and then I lose the ability to reconfigure the arrangements later. So, I'd like express.js to serve HTTP on its port, fulfilling some paths I specify by making HTTP requests to a secondary web application which is being served on another port.
Is there any middleware or other technique for express.js which will serve certain paths by making HTTP requests to other servers?
(The stackoverflow question How to make web service calls in Expressjs? is relevant but only discusses GET and I will have some POST requests to forward.)
Solution
With node-http-proxy only a single call to app.use is required to reverse proxy all unhandled requests, like this:
var app = express.createServer();
# my app.get bindings
app.use(require('http-proxy').createServer(80, 'other-server-address'));
app.listen(80);
Discussion
View additional discussion.