From 4658d0727323fdf8107f94c7b0a61c419e6504f6 Mon Sep 17 00:00:00 2001 From: sentriz Date: Wed, 20 Apr 2022 23:09:25 +0100 Subject: [PATCH] fix(lastfm): make a better guess at callback protocol when incoming connection is TLS closes: #213 Co-authored-by: Brian Doherty --- server/ctrlbase/ctrl.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/ctrlbase/ctrl.go b/server/ctrlbase/ctrl.go index 209505a6..93f17b36 100644 --- a/server/ctrlbase/ctrl.go +++ b/server/ctrlbase/ctrl.go @@ -56,8 +56,12 @@ func (c *Controller) Path(rel string) string { } func (c *Controller) BaseURL(r *http.Request) string { + protocol := "http" + if r.TLS != nil { + protocol = "https" + } scheme := firstExisting( - "http", // fallback + protocol, // fallback r.Header.Get("X-Forwarded-Proto"), r.Header.Get("X-Forwarded-Scheme"), r.URL.Scheme,