diff --git a/server/internal/httpapi/server.go b/server/internal/httpapi/server.go
index 5a7a712..01dd183 100644
--- a/server/internal/httpapi/server.go
+++ b/server/internal/httpapi/server.go
@@ -1148,7 +1148,7 @@ func (a *App) proxyLuCI(w http.ResponseWriter, r *http.Request, deviceID, sessio
}
rewriteLuCIHeaders(resp.Header, prefix)
contentType := resp.Header.Get("Content-Type")
- if !strings.Contains(contentType, "text/html") && !strings.Contains(contentType, "javascript") && !strings.Contains(contentType, "text/css") {
+ if !strings.Contains(contentType, "text/html") {
return nil
}
body, err := io.ReadAll(resp.Body)
diff --git a/server/internal/httpapi/server_test.go b/server/internal/httpapi/server_test.go
index 8464cbc..15e012b 100644
--- a/server/internal/httpapi/server_test.go
+++ b/server/internal/httpapi/server_test.go
@@ -425,6 +425,11 @@ func TestLuCIProxyRequiresActiveSessionAndRewritesPaths(t *testing.T) {
t.Fatal("LuCI route cookie leaked to LuCI upstream")
}
upstreamPath = r.URL.Path
+ if r.URL.Path == "/luci-static/resources/luci.js" {
+ w.Header().Set("Content-Type", "application/javascript")
+ _, _ = io.WriteString(w, `const untouched = '/cgi-bin/luci';`)
+ return
+ }
w.Header().Set("Content-Type", "text/html")
_, _ = io.WriteString(w, `LuCI`)
}))
@@ -510,6 +515,10 @@ func TestLuCIProxyRequiresActiveSessionAndRewritesPaths(t *testing.T) {
if upstreamPath != "/cgi-bin/luci/admin" {
t.Fatalf("LuCI fallback used upstream path %q", upstreamPath)
}
+ script := requestText(t, http.MethodGet, srv.URL+prefix+"/luci-static/resources/luci.js", "operator-test", nil, http.StatusOK)
+ if script != `const untouched = '/cgi-bin/luci';` {
+ t.Fatalf("LuCI JavaScript was unexpectedly rewritten: %s", script)
+ }
}
func TestServesStaticWebUI(t *testing.T) {