These days it’s pretty common for a system to consist of multiple separate applications – whether it’s microservices, Self-Contained Systems or something else entirely. Thus for development purposes, it might be necessary to spin up more than one application at a time (though hopefully not too many).
For web applications, it’s often necessary that collaborating systems be accessed via the same host (or origin), so having individual applications running on separate ports may be a problem – which can be remedied with a reverse proxy:
I’m assuming here that our applications are served on separate paths rather than, say, subdomains.
While conceptually straightforward, setting up a reverse proxy can be a bit of a pain. Apache and nginx are excellent for production systems, but typically overkill for local development and not trivial to configure.
Since modern web applications typically rely on Node.js tooling for front-end concerns, express-http-proxy seems like an obvious alternative. However, with its host of options, it can be a little intimidating as well – which is why I wrote a small wrapper providing a simplified, declarative way to set up a reverse proxy for local development:
After installing dprox via npm,
dprox will launch a reverse proxy listening at
localhost:3333. Now we just
have to start our applications and make sure they’re listening on the ports
we’ve configured here.