about summary refs log tree commit diff stats
path: root/internal/server
diff options
context:
space:
mode:
authorAlan Pearce2024-07-03 10:54:02 +0200
committerAlan Pearce2024-07-03 10:54:02 +0200
commit80c9717db80d9ead7c0c8a8693475ed0c2150470 (patch)
treed65b07060ce49ddad35b0974d86817338b528f27 /internal/server
parent5edc2c104cb94bc9ed8cf05f668822a651875add (diff)
downloadwebsite-80c9717db80d9ead7c0c8a8693475ed0c2150470.tar.lz
website-80c9717db80d9ead7c0c8a8693475ed0c2150470.tar.zst
website-80c9717db80d9ead7c0c8a8693475ed0c2150470.zip
fix HTTP->S redirects on standard port
Diffstat (limited to 'internal/server')
-rw-r--r--internal/server/tls.go7
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