Skip to content

Commit

Permalink
Revert "[GEN-1743]: serve root file for "404 file not found"" (#1810)
Browse files Browse the repository at this point in the history
Reverts #1794
  • Loading branch information
BenElferink authored Nov 20, 2024
1 parent 6536c09 commit 224d326
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions frontend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

Expand Down

0 comments on commit 224d326

Please sign in to comment.