refactor(webclient): adjust debug logging in Proxy.ServeHTTP to prevent logging full response body

- Moved HTML content log before body read to avoid exposing data - Removed log that included entire HTML body for security/privacy - Added log for non-HTML content to maintain debugging visibility

lemon-mint committed Oct 31, 2025 at 13:46 UTC 1cad78267e37a23463b608b11c75ee4bf4709fef
1 file changed +4 -1
cmd/webclient/main_js.go
+4 -1
@@ -91,16 +91,19 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
91
92 if r.Context().Value("http.request.mode").(string) == "navigate" &&
93 IsHTMLContentType(resp.Header.Get("Content-Type")) {
94 + log.Debug().Msgf("HTML content received")
95 +
96 body, err := io.ReadAll(resp.Body)
97 if err != nil {
98 w.WriteHeader(http.StatusBadGateway)
99 w.Write([]byte("502: Failed to read response body"))
100 return
101 }
100 - log.Debug().Msgf("HTML content received: %s", body)
102 w.WriteHeader(resp.StatusCode)
103 w.Write(body)
104 } else {
105 + log.Debug().Msgf("Non-HTML content received")
106 +
107 w.WriteHeader(resp.StatusCode)
108 io.Copy(w, resp.Body)
109 }