Skip to content

Instantly share code, notes, and snippets.

@bastibeckr
Created February 10, 2014 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bastibeckr/8912480 to your computer and use it in GitHub Desktop.
Save bastibeckr/8912480 to your computer and use it in GitHub Desktop.
HTTP Proxy for Web Development
var http = require('http'),
httpProxy = require('http-proxy');
var options = {
target: 'http://domain.dev/',
headers: {
host: 'domain.dev'
}
}
var proxy = httpProxy.createProxyServer({});
var server = require('http').createServer(function(req, res) {
console.log(JSON.stringify(req.headers, null, 2));
proxy.web(req, res, options );
});
console.log("listening on port 5050")
server.listen(5050);
{
"name": "httpproxy",
"description": "HTTP Proxy for Web Development",
"main": "index.js",
"dependencies": {
"http-proxy": "~1.0.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment