From 80c9717db80d9ead7c0c8a8693475ed0c2150470 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Wed, 3 Jul 2024 10:54:02 +0200 Subject: fix HTTP->S redirects on standard port --- internal/server/tls.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/server/tls.go b/internal/server/tls.go index 1a79e9c..71dde54 100644 --- a/internal/server/tls.go +++ b/internal/server/tls.go @@ -110,7 +110,12 @@ func (s *Server) serveTLS() (err error) { log.Warn("error splitting host and port", "error", err) host = s.config.BaseURL.Hostname() } - url.Host = net.JoinHostPort(host, s.config.BaseURL.Port()) + port := s.config.BaseURL.Port() + if port == "" { + url.Host = host + } else { + url.Host = net.JoinHostPort(host, s.config.BaseURL.Port()) + } http.Redirect(w, r, url.String(), http.StatusMovedPermanently) }) srv.Handler = httpMux -- cgit 1.4.1