From 6c1882911a34f45db2bcc7e374cdd6650825aa07 Mon Sep 17 00:00:00 2001 From: miyuko Date: Mon, 20 Jul 2026 15:08:47 +0100 Subject: [PATCH] Expose `X-Server` when responding to mutating requests. Resolves: https://codeberg.org/git-pages/git-pages/issues/209 --- src/pages.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pages.go b/src/pages.go index d481e87..0e97078 100644 --- a/src/pages.go +++ b/src/pages.go @@ -950,6 +950,11 @@ func ServePages(w http.ResponseWriter, r *http.Request) { } else { w.Header().Add("Server", "git-pages") } + if !slices.Contains([]string{"GET", "HEAD"}, r.Method) { + // Expose a header for git-pages-cli (which only cares about one for mutating requests) + // to work around proxying CDNs like Cloudflare &co. + w.Header()["X-Server"] = append(w.Header()["X-Server"], w.Header()["Server"]...) + } allowedMethods := []string{"OPTIONS", "HEAD", "GET", "PUT", "PATCH", "DELETE", "POST"} if r.Method == "OPTIONS" || !slices.Contains(allowedMethods, r.Method) { w.Header().Add("Allow", strings.Join(allowedMethods, ", "))