Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[GEN-1743]: serve root file for "404 file not found"" #1810

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading