Skip to content

Commit d6623d7

Browse files
committed
fix rootpath being unsable
1 parent b479122 commit d6623d7

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

internal/frontend/http.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,20 @@ func (handler *SSRHandler) SetupRoutes(register func(string, string, http.Handle
123123
}
124124

125125
indexHandler := handler.cspMiddleware(handler.indexPageHandler)
126-
register("GET", handler.cfg.RootPath, func(w http.ResponseWriter, r *http.Request) {
127-
if r.URL.Path == "" || r.URL.Path == "/" {
128-
indexHandler(w, r)
129-
return
130-
}
131-
132-
if genericFileHandler != nil {
133-
genericFileHandler.ServeHTTP(w, r)
134-
}
135-
})
126+
register("GET", handler.cfg.RootPath,
127+
http.StripPrefix(
128+
"/"+handler.cfg.RootPath,
129+
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
130+
println(r.URL.Path)
131+
if r.URL.Path == "" || r.URL.Path == "/" {
132+
indexHandler(w, r)
133+
return
134+
}
135+
136+
if genericFileHandler != nil {
137+
genericFileHandler.ServeHTTP(w, r)
138+
}
139+
})).ServeHTTP)
136140

137141
fileServer := http.FileServer(http.FS(frontendResourcesFS))
138142
register(

0 commit comments

Comments
 (0)