diff --git a/server/main.go b/server/main.go index 2f2617d..aef3b7e 100644 --- a/server/main.go +++ b/server/main.go @@ -120,9 +120,23 @@ func main() { // Static files if cfg.WebStaticPath != "" { - r.Static("/", cfg.WebStaticPath) + staticFS := os.DirFS(cfg.WebStaticPath) + fileServer := http.FileServer(http.FS(staticFS)) r.NoRoute(func(c *gin.Context) { - c.File(cfg.WebStaticPath + "/index.html") + path := c.Request.URL.Path + // Handle assets at any path depth + if idx := strings.Index(path, "/assets/"); idx >= 0 { + c.Request.URL.Path = path[idx:] + fileServer.ServeHTTP(c.Writer, c.Request) + return + } + if path == "/favicon.ico" { + fileServer.ServeHTTP(c.Writer, c.Request) + return + } + // SPA fallback: all other paths serve index.html + c.Request.URL.Path = "/" + fileServer.ServeHTTP(c.Writer, c.Request) }) } else { staticFS, err := fs.Sub(webFS, "static")