Skip to content

Instantly share code, notes, and snippets.

@mmautner
Created June 13, 2014 16:03
Show Gist options
  • Save mmautner/eaa3f68ead87e153addb to your computer and use it in GitHub Desktop.
Save mmautner/eaa3f68ead87e153addb to your computer and use it in GitHub Desktop.
proxying requests to "/api/*" to an external HTTP API
var http = require('http'),
, httpProxy = require('http-proxy')
, express = require('express');
app = express();
var apiUrl = 'http://api.example.com:80';
var proxy = httpProxy.createProxyServer({target:apiUrl});
app.all('/api/*', function(req, res) {
proxy.web(req, res, function(e) { console.log(e); });
});
app.listen(3030);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment