Fixed serving admin frontend.

This commit is contained in:
2023-07-18 23:45:59 +02:00
parent b5860b4f64
commit 6c47cf18b4

View File

@@ -11,6 +11,7 @@ import (
"net/http"
"os"
"os/signal"
"path/filepath"
"time"
)
@@ -52,17 +53,11 @@ func main() {
http.ServeFile(w, r, "cmd/admin/dist/index.html")
})
} else {
r.Handle("/assets/*", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// TODO http.StripPrefix("/admin/assets/",
log.Println(r.URL.Path)
d, err := assets.ReadFile("admin/dist/assets/index-e8823577.css")
if err != nil {
log.Println(err)
}
w.Write(d)
}))
fs := http.FileServer(http.FS(assets))
r.Handle("/assets/*", http.StripPrefix("/admin/assets/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
r.URL.Path = filepath.Join("admin/dist/assets", r.URL.Path)
fs.ServeHTTP(w, r)
})))
r.Get("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "image/x-icon")