From 120ae2bcbe434ce9bde8ee06a6d2225d2c932914 Mon Sep 17 00:00:00 2001 From: Pulse Monitor Date: Sat, 30 Aug 2025 22:48:53 +0000 Subject: [PATCH] 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 --- internal/api/config_handlers.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/api/config_handlers.go b/internal/api/config_handlers.go index 916c92c6f..686e55002 100644 --- a/internal/api/config_handlers.go +++ b/internal/api/config_handlers.go @@ -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 != "" {