Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Easy local development with a node.js proxy
"name": "your-app-name",
"version": "0.0.1",
"private": true,
"dependencies": {
"http-proxy": "0.8.x",
"connect": "2.3.x"
var httpProxy = require('http-proxy'),
connect = require('connect'),
endpoint = {
host: '', // or IP address
port: 80,
prefix: '/api'
staticDir = 'public';
var proxy = new httpProxy.RoutingProxy();
var app = connect()
.use(function(req, res) {
if (req.url.indexOf(endpoint.prefix) === 0) {
proxy.proxyRequest(req, res, endpoint);
// http://localhost:4242/api/test will give response
// from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.