Replies: 2 comments 2 replies
-
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: |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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!
`
Beta Was this translation helpful? Give feedback.
All reactions