From 4ccb16ea4e80e240a3e83c79aaef936e45c1a28d Mon Sep 17 00:00:00 2001 From: Ben Elferink Date: Wed, 20 Nov 2024 20:52:49 +0200 Subject: [PATCH] Revert "[GEN-1743]: serve root file for "404 file not found" (#1794)" This reverts commit 67af0aa84ce220e21475c39ba8ec20ef9a037489. --- frontend/main.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) 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) }) }