From a90f41e6388e8fce196f188795347f2798f563a7 Mon Sep 17 00:00:00 2001 From: huanld Date: Fri, 10 Apr 2026 22:45:06 +0700 Subject: [PATCH] fix: serve static files at root using fs.Sub --- web-admin/main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web-admin/main.go b/web-admin/main.go index 7bee20a2f..8fc87859e 100644 --- a/web-admin/main.go +++ b/web-admin/main.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "io" + "io/fs" "log" "net/http" "os" @@ -47,8 +48,12 @@ func main() { mux.HandleFunc("/api/routes/", authMiddleware(handleRouteByID)) mux.HandleFunc("/api/auth", handleAuth) - // Static files - mux.Handle("/", http.FileServer(http.FS(staticFS))) + // Static files - strip "static" prefix so files are served at / + staticSub, err := fs.Sub(staticFS, "static") + if err != nil { + log.Fatal(err) + } + mux.Handle("/", http.FileServer(http.FS(staticSub))) log.Printf("Headscale Web Admin starting on %s", listenAddr) log.Printf("Headscale API: %s", headscaleURL)