Reputation: 342
I'm trying to set up a proxy with logging in Node.js. I have tried doing it like https://github.com/nodejitsu/node-http-proxy#listening-for-proxy-events
The proxy works, but it seems the end event is not called - nothing is output to the console when I access the page. What am I missing?
var httpProxy = require('http-proxy');
var server = httpProxy.createServer(function (req, res, proxy) {
var buffer = httpProxy.buffer(req);
proxy.proxyRequest(req, res, {
host: 'nodejs.org',
port: 80,
buffer: buffer
});
});
server.proxy.on('end', function() {
console.log("The request was proxied.");
});
server.listen(8000);
Upvotes: 0
Views: 480
Reputation: 532
You aren't missing anything - it's a bug. The fix is already on master branch. It hasn't been deployed to npm yet, though.
Upvotes: 1