CODE-688: All static assets must be served from the root path

This commit is contained in:
“tan-nhu” 2023-08-07 14:26:13 -07:00
parent 2b6e75682d
commit a8b48d228d

View File

@ -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