Turns out that node can do this and it's very easy to do. In just 12 lines of my own code I had a reverse proxy that would do url rewriting. Check it out.
This file contains 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'); | |
var httpProxy = require('http-proxy'); | |
var proxy = httpProxy.createProxyServer(); | |
http.createServer(function(req, res){ | |
if(/^\/api/.test(req.url)){ | |
req.url = req.url.replace(/^\/api/, ""); | |
proxy.web(req, res, {target:'http://localhost:7889'}); | |
} else { | |
proxy.web(req, res, {target:'http://localhost:6789'}); | |
} | |
}).listen(2020); | |