Created
June 13, 2014 16:03
-
-
Save mmautner/eaa3f68ead87e153addb to your computer and use it in GitHub Desktop.
proxying requests to "/api/*" to an external HTTP API
This file contains hidden or 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'), | |
, 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