From a8b48d228d32a83d79bd01fdc8d02f05b22cf05c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Ctan-nhu=E2=80=9D?= <“tan@harness.io”> Date: Mon, 7 Aug 2023 14:26:13 -0700 Subject: [PATCH] CODE-688: All static assets must be served from the root path --- web/dist.go | 5 +++++ 1 file changed, 5 insertions(+) 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