Created
December 4, 2015 16:17
-
-
Save mrded/540aa79a42f74a4911e8 to your computer and use it in GitHub Desktop.
CORS Proxy on node.js + express
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 express = require('express'), | |
request = require('request'); | |
var app = express(); | |
// Forward all requests from /api to http://foo.com/api | |
app.use('/api', function(req, res) { | |
req.pipe(request("http://foo.com/api" + req.url)).pipe(res); | |
}); | |
app.listen(process.env.PORT || 3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment