-
-
Save dustin/bf62443ce52ae3e8604f to your computer and use it in GitHub Desktop.
The couch auth proxy.
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'); | |
var url = require('url'); | |
var PORT=8675; | |
function handleReq(req, res) { | |
var preq = url.parse(req.url, true); | |
var myheaders = req.headers; | |
delete myheaders['host']; | |
delete myheaders['connection']; | |
myheaders['Authorization'] = 'Basic Something=='; | |
myheaders['Connection'] = 'close'; | |
var options = { | |
host: 'single.couchbase.net', | |
port: 80, | |
path: req.url, | |
method: req.method, | |
headers: myheaders | |
}; | |
console.log("Fetching", req.url); | |
var creq = http.request(options, function(cres) { | |
console.log("Got", cres.statusCode); | |
res.writeHead(cres.statusCode, cres.headers); | |
cres.pipe(res); | |
}); | |
req.pipe(creq); | |
} | |
http.createServer(handleReq).listen(PORT, "0.0.0.0"); | |
console.log('Server running at http://0.0.0.0:' + PORT + '/'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment