Skip to content

Commit

Permalink
fix rootpath being unsable
Browse files Browse the repository at this point in the history
  • Loading branch information
Bios-Marcel committed Jan 14, 2025
1 parent b479122 commit d6623d7
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions internal/frontend/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,20 @@ func (handler *SSRHandler) SetupRoutes(register func(string, string, http.Handle
}

indexHandler := handler.cspMiddleware(handler.indexPageHandler)
register("GET", handler.cfg.RootPath, func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "" || r.URL.Path == "/" {
indexHandler(w, r)
return
}

if genericFileHandler != nil {
genericFileHandler.ServeHTTP(w, r)
}
})
register("GET", handler.cfg.RootPath,
http.StripPrefix(
"/"+handler.cfg.RootPath,
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
println(r.URL.Path)
if r.URL.Path == "" || r.URL.Path == "/" {
indexHandler(w, r)
return
}

if genericFileHandler != nil {
genericFileHandler.ServeHTTP(w, r)
}
})).ServeHTTP)

fileServer := http.FileServer(http.FS(frontendResourcesFS))
register(
Expand Down

0 comments on commit d6623d7

Please sign in to comment.