From 769c7f205ec1235dd212d6315730aa036fe75175 Mon Sep 17 00:00:00 2001 From: OpenClaw Agent Date: Mon, 21 Sep 2026 20:24:30 +0800 Subject: [PATCH] fix: align direct file serving with CHFS routes --- chfs-ng/internal/api/server.go | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/chfs-ng/internal/api/server.go b/chfs-ng/internal/api/server.go index a53cc3a..c2faa7a 100644 --- a/chfs-ng/internal/api/server.go +++ b/chfs-ng/internal/api/server.go @@ -564,6 +564,10 @@ func (s *Server) shared(w http.ResponseWriter, r *http.Request) { _, _ = io.WriteString(w, "\n") return } + if r.Method != http.MethodGet { + http.NotFound(w, r) + return + } f, err := s.Store.Open(p) if err != nil { http.NotFound(w, r) @@ -611,20 +615,7 @@ func (s *Server) preview(w http.ResponseWriter, r *http.Request) { } func (s *Server) fileHandler(w http.ResponseWriter, r *http.Request) { - if r.URL.Path == "/" || strings.HasPrefix(r.URL.Path, "/asset/") { - http.NotFound(w, r) - return - } - if strings.HasPrefix(r.URL.Path, "/chfs/") || r.URL.Path == "/webdav" { - http.NotFound(w, r) - return - } - p := strings.Trim(strings.ReplaceAll(r.URL.Path, "\\", "/"), "/") - if p == "" { - http.NotFound(w, r) - return - } - s.serveFile(w, r, p, false) + http.NotFound(w, r) } func (s *Server) serveFile(w http.ResponseWriter, r *http.Request, p string, attachment bool) {