feat: optimizar deteccion HTTPS y registrar puesta en produccion publica con Apache SSL
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user