diff --git a/web/dist.go b/web/dist.go index 58adb79c5..7ff754f9f 100644 --- a/web/dist.go +++ b/web/dist.go @@ -11,6 +11,7 @@ import ( "io/fs" "net/http" "os" + "path" "path/filepath" "time" @@ -36,6 +37,7 @@ func Handler() http.HandlerFunc { // http.FileServer to always load the index.html // file if a directory path is being requested. return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // because this is a single page application, // we need to always load the index.html file // in the root of the project, unless the path @@ -44,6 +46,9 @@ func Handler() http.HandlerFunc { // HACK: alter the path to point to the // root of the project. r.URL.Path = "/" + } else { + // All static assets are served from the root path + r.URL.Path = "/" + path.Base(r.URL.Path) } // Disable caching and sniffing via HTTP headers for UI main entry resources