diff --git a/internal/web/ui.go b/internal/web/ui.go index 313ab86..fd688fd 100644 --- a/internal/web/ui.go +++ b/internal/web/ui.go @@ -662,7 +662,7 @@ func (u *UI) Routes() (chi.Router, error) { r.Get("/diagnostics", u.pageDiagnostics) r.Get("/alarms", u.pageAlarms) r.Get("/monitor", u.pageMonitor) - r.Get("/hls/{deviceID}/*", u.proxyHLS) + r.Get("/hls/*", u.proxyHLS) r.Get("/api/monitor/channels", u.apiMonitorChannels) r.Get("/recognition", u.pageRecognition) r.Get("/logs", u.pageLogs) @@ -3894,17 +3894,20 @@ func (u *UI) apiMonitorChannels(w http.ResponseWriter, r *http.Request) { } func (u *UI) proxyHLS(w http.ResponseWriter, r *http.Request) { - deviceID := chi.URLParam(r, "deviceID") + // URL format: /hls/{deviceID}/{hls_path} + path := strings.TrimPrefix(r.URL.Path, "/hls/") + idx := strings.Index(path, "/") + if idx < 0 { + http.Error(w, "invalid path", http.StatusBadRequest) + return + } + deviceID := path[:idx] + hlsPath := path[idx+1:] dev, ok := u.findDevice(deviceID) if !ok { http.Error(w, "device not found", http.StatusNotFound) return } - hlsPath := chi.URLParam(r, "*") - if hlsPath == "" { - http.Error(w, "missing path", http.StatusBadRequest) - return - } body, code, err := u.agent.Do("GET", dev.IP, dev.MediaPort, "/"+hlsPath, nil) if err != nil { http.Error(w, err.Error(), http.StatusBadGateway)