diff options
author | Simon <simon@hilchenba.ch> | 2020-11-28 18:52:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-28 19:52:30 +0200 |
commit | 8c996c65053296e997718265c4f4cb08c2d9dffb (patch) | |
tree | 22cda270c4c60d9f0a7863cfb8519c18090aa588 | |
parent | 1e5247d424de7f8a480c73b0b72119ae5482edf1 (diff) | |
download | gitea-8c996c65053296e997718265c4f4cb08c2d9dffb.tar.gz gitea-8c996c65053296e997718265c4f4cb08c2d9dffb.zip |
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 <xiaolunwen@gmail.com> for finding the quirk
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
-rw-r--r-- | routers/routes/chi.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/routers/routes/chi.go b/routers/routes/chi.go index 5ff7a728ff..00689441b7 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) }) |