From 0efeb08a3774e7b173bcdd2838620a2f62a96d92 Mon Sep 17 00:00:00 2001 From: Abhishek Shroff Date: Tue, 27 May 2025 23:19:28 +0530 Subject: [PATCH] [server] Only serve static files if path doesn't match api, publinks, or webdav --- server/internal/command/serve/cmd.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/internal/command/serve/cmd.go b/server/internal/command/serve/cmd.go index 504cc3bb..e4cdafb9 100644 --- a/server/internal/command/serve/cmd.go +++ b/server/internal/command/serve/cmd.go @@ -5,6 +5,7 @@ import ( "net/http" "path" "strconv" + "strings" "time" "github.com/fvbock/endless" @@ -77,7 +78,11 @@ func setupWebApp(r gin.IRoutes, webAppSrcDir string) { indexFilePath := path.Join(webAppSrcDir, "index.html") staticFileHandler := func(c *gin.Context) { - if c.Request.Method == "GET" { + path := c.Request.URL.Path + if c.Request.Method == "GET" && + !strings.HasPrefix(path, "/api") && + !strings.HasPrefix(path, Cfg.WebDAVPath) && + !strings.HasPrefix(path, Cfg.PublinkPath) { c.Writer.Header().Set("Cross-Origin-Embedder-Policy", "credentialless") c.Writer.Header().Set("Cross-Origin-Opener-Policy", "same-origin") if fs.Exists("/", c.Request.URL.Path) {