diff --git a/go_cloud/internal/http/routes.go b/go_cloud/internal/http/routes.go index f1aaf55..7135e87 100644 --- a/go_cloud/internal/http/routes.go +++ b/go_cloud/internal/http/routes.go @@ -367,7 +367,9 @@ func viewerHandler(w http.ResponseWriter, r *http.Request, db *database.DB, audi // Build download URL with proper URL encoding using the request's scheme and host scheme := "https" - if r.TLS == nil { + if proto := r.Header.Get("X-Forwarded-Proto"); proto != "" { + scheme = proto + } else if r.TLS == nil { scheme = "http" } host := r.Host @@ -431,7 +433,9 @@ func userViewerHandler(w http.ResponseWriter, r *http.Request, db *database.DB, // Build download URL with proper URL encoding using the request's scheme and host scheme := "https" - if r.TLS == nil { + if proto := r.Header.Get("X-Forwarded-Proto"); proto != "" { + scheme = proto + } else if r.TLS == nil { scheme = "http" } host := r.Host