Match on the full request URL when applying headers.

Fixes: https://codeberg.org/git-pages/git-pages/issues/206
This commit is contained in:
miyuko
2026-06-19 02:44:58 +01:00
committed by Catherine
parent 4cc8d58548
commit 43dec6032a
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ func configureFeatures(ctx context.Context) (err error) {
for _, feature := range config.Features {
switch feature {
// Work-in-progress features:
case "preview", "expiration":
case "preview", "expiration", "absolute-headers":
// Permanently unstable features:
case "codeberg-pages-compat", "relaxed-idna":
// Stabilized features:
+5 -1
View File
@@ -446,7 +446,11 @@ func getPage(w http.ResponseWriter, r *http.Request) error {
w.Header().Set("Content-Type", *entry.ContentType)
}
customHeaders, err := ApplyHeaderRules(manifest, &url.URL{Path: entryPath})
headersMatchURL := &url.URL{Path: entryPath}
if config.Feature("absolute-headers") {
headersMatchURL = (&url.URL{Host: r.Host}).ResolveReference(r.URL)
}
customHeaders, err := ApplyHeaderRules(manifest, headersMatchURL)
if err != nil {
// This is an "internal server error" from an HTTP point of view, but also
// either an issue with the site or a misconfiguration from our point of view.