Skip to content

Instantly share code, notes, and snippets.

@mrded
Created December 4, 2015 16:17
Show Gist options
  • Save mrded/540aa79a42f74a4911e8 to your computer and use it in GitHub Desktop.
Save mrded/540aa79a42f74a4911e8 to your computer and use it in GitHub Desktop.
CORS Proxy on node.js + express
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