Skip to content

Commit

Permalink
Revert "[GEN-1743]: serve root file for "404 file not found" (#1794)"
Browse files Browse the repository at this point in the history
This reverts commit 67af0aa.
  • Loading branch information
BenElferink authored Nov 20, 2024
1 parent 6536c09 commit 4ccb16e
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 4ccb16e

Please sign in to comment.