From 8c996c65053296e997718265c4f4cb08c2d9dffb Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 28 Nov 2020 18:52:30 +0100 Subject: [PATCH] Fix missing stylesheets on installation page (#13736) When running gitea for the first time, the stylesheets for the installation page are broken since the middleware that statically serves stylesheets does not get executed by chi. This is because if no handlers are registered in chi, it will drop all middleware. This commit introduces a "dummy" handler to deal with that quirk. Closes #13725 Thanks: Lunny Xiao for finding the quirk Co-authored-by: Lunny Xiao --- routers/routes/chi.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/routers/routes/chi.go b/routers/routes/chi.go index 5ff7a728f..00689441b 100644 --- a/routers/routes/chi.go +++ b/routers/routes/chi.go @@ -230,6 +230,12 @@ func RegisterInstallRoute(c chi.Router) { m := NewMacaron() RegisterMacaronInstallRoute(m) + // We need at least one handler in chi so that it does not drop + // our middleware: https://github.com/go-gitea/gitea/issues/13725#issuecomment-735244395 + c.Get("/", func(w http.ResponseWriter, req *http.Request) { + m.ServeHTTP(w, req) + }) + c.NotFound(func(w http.ResponseWriter, req *http.Request) { m.ServeHTTP(w, req) })