From 8f536a3b6a915cfb2f2fff909d52ba7354b6315a Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Wed, 4 Dec 2024 19:59:33 +0100 Subject: server: 404 if host not recognised --- internal/server/server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'internal/server/server.go') diff --git a/internal/server/server.go b/internal/server/server.go index b327f3d..ba825aa 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -194,10 +194,12 @@ func New(runtimeConfig *Config, log *log.Logger) (*Server, error) { path, _ := website.CanonicalisePath(r.URL.Path) newURL := config.BaseURL.JoinPath(path) http.Redirect(w, r, newURL.String(), http.StatusMovedPermanently) - } else { + } else if re.MatchString(r.Host) { url := config.BaseURL url.Host = re.ReplaceAllString(r.Host, replace) http.Redirect(w, r, url.String(), http.StatusTemporaryRedirect) + } else { + http.NotFound(w, r) } }) } else { -- cgit 1.4.1