diff --git a/src/main.go b/src/main.go index e1d63d1..3d7606b 100644 --- a/src/main.go +++ b/src/main.go @@ -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: diff --git a/src/pages.go b/src/pages.go index 0d48b5a..d481e87 100644 --- a/src/pages.go +++ b/src/pages.go @@ -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.