fix: detect HTTPS protocol when behind reverse proxy for setup scripts

addresses #394 - setup script now correctly uses https:// in generated commands
when Pulse is running behind an HTTPS reverse proxy like Traefik by checking
the X-Forwarded-Proto header
This commit is contained in:
Pulse Monitor
2025-08-30 22:48:53 +00:00
parent 4a5086b378
commit 120ae2bcbe
+5 -3
View File
@@ -2714,10 +2714,12 @@ func (h *ConfigHandlers) HandleSetupScriptURL(w http.ResponseWriter, r *http.Req
// For production, keep the original host (users will need proper proxy config)
}
pulseURL := fmt.Sprintf("%s://%s", "http", host)
if r.TLS != nil {
pulseURL = fmt.Sprintf("%s://%s", "https", host)
// Detect protocol - check both TLS and proxy headers
scheme := "http"
if r.TLS != nil || r.Header.Get("X-Forwarded-Proto") == "https" {
scheme = "https"
}
pulseURL := fmt.Sprintf("%s://%s", scheme, host)
encodedHost := ""
if req.Host != "" {