diff options
author | Alan Pearce | 2024-07-03 10:54:02 +0200 |
---|---|---|
committer | Alan Pearce | 2024-07-03 10:54:02 +0200 |
commit | 80c9717db80d9ead7c0c8a8693475ed0c2150470 (patch) | |
tree | d65b07060ce49ddad35b0974d86817338b528f27 | |
parent | 5edc2c104cb94bc9ed8cf05f668822a651875add (diff) | |
download | website-80c9717db80d9ead7c0c8a8693475ed0c2150470.tar.lz website-80c9717db80d9ead7c0c8a8693475ed0c2150470.tar.zst website-80c9717db80d9ead7c0c8a8693475ed0c2150470.zip |
fix HTTP->S redirects on standard port
-rw-r--r-- | internal/server/tls.go | 7 |
1 files changed, 6 insertions, 1 deletions
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 |