Last active
January 4, 2016 19:29
-
-
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
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'), | |
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 | |
*/ |
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
{ | |
"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