-
Notifications
You must be signed in to change notification settings - Fork 825
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transfer-Encoding chunked and routing seems to cause a problem #324
Comments
Hi @vansen First time I see this issue. Can you try to reproduce it with an minimal setup; If problem still persist you can try same minimal setup and replace it with An http-proxy example can be found here: |
Thanks for your reply, I got it solved at least for now. Further testing is being done currently. I registered to the ProxyRes event and if the destination sends a chunked response, I am currently overwriting that and passing it on "unchunked" by simply removing the transfer-encoding header. This post from nodejitsu got me into the right direction: http-party/node-http-proxy#1007 onProxyRes: function OnProxyRes(proxyRes, req, res) {
// Capture the response from the backend and check if response is being chunked
var chunked = /chunked/.test(proxyRes.headers["transfer-encoding"]);
if (chunked) {
// If chunked, then gather all chunks and pass it on unchunked. Remove transfer-encoding header.
proxyRes.headers["transfer-encoding"] = '';
res.write = (function(override) {
return function(chunk, encoding, callback) {
override.call(res, chunk, "binary", callback);
};
})(res.write);
res.end = (function(override) {
return function(chunk, encoding, callback) {
override.call(res, chunk, "binary", callback);
};
})(res.end);
} edit: formatting |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hi everyone,
I am using the http-proxy-middleware inside the node express server. I have setup routing to be done for certain paths, like "api" in this case.
I found everything working fine, but when I encounter a longer response that is being sent from the Backend (API) my Browser receives the following error:
ERR_CONTENT_DECODING_FAILED. I also check if the content passed might be invalid but this is not the case. It is also properly formatted in UTF8.
When I directly address the backend - bypassing the routing I get the correct result, along with the Transfer-Encoding: chunked header. This seems to cause the above problem.
My server.js code looks like this- additionally to the routing I need to check if the url contains "UI" or "API" because I am using a react app where I need to pass on to the index.html file to get it handled. Can anyone please give a hint to where it might be going wrong? Target and routing urls have been "xxx"-ed. The response content is ~500 KB uncompressed, so should not be way too big.
Thanks!
`
The text was updated successfully, but these errors were encountered: