Cannot use connect.compress() middleware with http-proxy
Created by: fmarier
Looking at the middleware example that comes with http-proxy:
I decided to write my own program which makes use of connect.compress() but is otherwise the same as the example that comes with http-proxy:
https://github.com/fmarier/node-compressed-http-proxy/blob/master/compress-example.js
Unfortunately, it doesn't work because the compress middleware looks at the headers before they are written out in order to decide whether or not a resource should be compressed. I can force compress to always compress everything by calling it like this:
connect.compress({filter: function () {return true;}})
but that's of course not a good idea since images will get gzipped too.
The result is that proxied content is never compressed by connect.compress().