feat: optimizar deteccion HTTPS y registrar puesta en produccion publica con Apache SSL

This commit is contained in:
2026-10-20 10:49:10 -05:00
parent 69a3ee98e6
commit 8fedd61318
5 changed files with 12 additions and 4 deletions
+7 -1
View File
@@ -72,7 +72,10 @@ type PageData struct {
func (h *Handlers) getBaseURL(r *http.Request) string {
proto := "http"
if r.TLS != nil || r.Header.Get("X-Forwarded-Proto") == "https" {
if r.TLS != nil ||
strings.EqualFold(r.Header.Get("X-Forwarded-Proto"), "https") ||
strings.EqualFold(r.Header.Get("X-Forwarded-Ssl"), "on") ||
r.Header.Get("X-Forwarded-Port") == "443" {
proto = "https"
}
host := r.Host
@@ -80,6 +83,9 @@ func (h *Handlers) getBaseURL(r *http.Request) string {
host = r.Header.Get("X-Forwarded-Host")
}
if host != "" {
if strings.HasPrefix(h.cfg.BaseURL, "https://") && strings.Contains(h.cfg.BaseURL, host) {
proto = "https"
}
return fmt.Sprintf("%s://%s", proto, host)
}
return h.cfg.BaseURL