main
DustyP 9 months ago
parent 589c9ebe19
commit 3724f2e47d

@ -8,6 +8,7 @@ import (
"io/fs" "io/fs"
"log" "log"
"net/http" "net/http"
"net/url"
"strings" "strings"
"sync" "sync"
"time" "time"
@ -79,9 +80,18 @@ func (s *Server) routes() {
w.Header().Set("Content-Type", "text/css") w.Header().Set("Content-Type", "text/css")
} }
// Strip /static/ prefix before serving // The key fix: properly handle the path
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/static") // Remove the /static prefix for the filesystem lookup
fileServer.ServeHTTP(w, r) pathWithoutPrefix := strings.TrimPrefix(r.URL.Path, "/static")
// Create a new request with the modified path
r2 := new(http.Request)
*r2 = *r
r2.URL = new(url.URL)
*r2.URL = *r.URL
r2.URL.Path = pathWithoutPrefix
fileServer.ServeHTTP(w, r2)
}) })
// API routes // API routes

Loading…
Cancel
Save