How to fix ERR_INVALID_CHUNKED_ENCODING error?

24.7k Views Asked by At

I have a Clojure application that acts as a proxy service. The goal is to proxy requests to http://127.0.0.1:3000 (Grafana service) through the path "/grafana", so that if I access http://127.0.0.1/grafana through the browser, it should proxy my request to port 3000 and display the UI for Grafana.

The issue I'm running into is that I get an ERR_INVALID_CHUNKED_ENCODING response in the browser. In Wireshark, requests to port 3000 show that the HTTP response reassembles 3 TCP packets. However, the response for requests going through my proxy are not being reassembled, resulting in the chunking error. Anyone have any ideas on how to resolve this?

Thanks.

1

There are 1 best solutions below

3
On BEST ANSWER

The issue was caused when returning the response from my proxy service to the browser. The response contained the header Transfer-Encoding: chunked. This header was necessary when the response went from Grafana -> proxy-service, but not required when going from proxy-service -> browser. So the solution was to remove that header before sending the response back to the browser.