Created
February 10, 2014 08:48
-
-
Save bastibeckr/8912480 to your computer and use it in GitHub Desktop.
HTTP Proxy for Web Development
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 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); |
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": "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