Skip to content

Instantly share code, notes, and snippets.

@alex-alex2006hw
Forked from mrded/server.js
Created June 30, 2018 07:53
Show Gist options
  • Save alex-alex2006hw/3863645fea2219f0cbd9fe19ada3e060 to your computer and use it in GitHub Desktop.
Save alex-alex2006hw/3863645fea2219f0cbd9fe19ada3e060 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