diff --git a/frontend/main.go b/frontend/main.go index 571b12b79..0fb09570e 100644 --- a/frontend/main.go +++ b/frontend/main.go @@ -124,21 +124,14 @@ func startHTTPServer(flags *Flags, odigosMetrics *collectormetrics.OdigosMetrics } func httpFileServerWith404(fs http.FileSystem) http.Handler { - // Init outside of handler to respect manipulated paths - fileServer := http.FileServer(fs) return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - path := r.URL.Path - - // Check if the requested file exists - _, err := fs.Open(path) + _, err := fs.Open(r.URL.Path) if err != nil { - // Redirect to root path - r.URL.Path = "/index.html" + // Serve index.html + r.URL.Path = "/" } - - // Serve the file - fileServer.ServeHTTP(w, r) + http.FileServer(fs).ServeHTTP(w, r) }) }