Skip to content

Instantly share code, notes, and snippets.

@joeriks
Last active January 4, 2016 19:29
Show Gist options
  • Save joeriks/8667501 to your computer and use it in GitHub Desktop.
Save joeriks/8667501 to your computer and use it in GitHub Desktop.
Very simple nodejs+express proxy = servs all url's from the proxied to localhost:1235 - and it supports POST, PUT et c
var express = require('express'),
app = express.createServer(),
request = require('request');
app.listen(process.env.PORT || 1235);
app.use('/hello',function (req, res) {
res.send('This comes from node w express');
});
app.all('/*', function(req, res) {
url = "http://www.mysite.com" + req.url;
req.pipe(request(url)).pipe(res);
});
/*
ref: http://stackoverflow.com/questions/7559862/proxy-with-nodejs-and-express
*/
{
"name": "simpleproxy",
"version": "0.0.0",
"description": "ERROR: No README.md file found!",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": "",
"author": "",
"license": "BSD",
"devDependencies": {
"pipe": "~1.0.0",
"request": "~2.33.0",
"express": "~3.4.8"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment