gevorg/http-auth — Issue #4: Using Basic/Digest Auth with http-proxy
Author: digitalrinaldo
Created: 2011-11-15 13:48:08+00:00
State: open

Hi,

Thanks for the very useful addition. I am trying to get the following to work. Any ideas on how to use http-auth and http-proxy together.

httpProxy.createServer(function (req, res, proxy) {

console.log("Here");

digest.apply(req, res, function() {
res.end("Welcome to private area!");
});

proxy.proxyRequest(req, res, {
host: 'localhost',
port: 5984
});
}).listen(8000);

I get the following:

Express server listening on port 8081 in development mode
Here

http.js:573
throw new Error("Can't render headers after they are sent to the client.")
^
Error: Can't render headers after they are sent to the client.
at ServerResponse. (http.js:573:11)
at ServerResponse._renderHeaders (/opt/maxwell/admin/node_modules/express/node_modules/connect/lib/patch.js:76:25)
at ServerResponse.writeHead (http.js:816:20)
at ClientRequest. (/opt/maxwell/admin/node_modules/http-proxy/lib/node-http-proxy/http-proxy.js:214:9)
at ClientRequest.emit (events.js:67:17)
at HTTPParser.onIncoming (http.js:1217:11)
at HTTPParser.onHeadersComplete (http.js:102:31)
at Socket.ondata (http.js:1116:24)
at TCP.onread (net.js:314:27)