fix: serve static files at root using fs.Sub

This commit is contained in:
2026-04-10 22:45:06 +07:00
parent 5f18a2f925
commit a90f41e638
+7 -2
View File
@@ -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)