From e01b9b036bcc82a81c9fe3b1052fd38efece9687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Urban?= Date: Mon, 16 Oct 2023 20:15:15 +0200 Subject: [PATCH] fix(backend): add correct source header for redirect url --- backend/internal/handlers/auth.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/internal/handlers/auth.go b/backend/internal/handlers/auth.go index 9722eea..6fea815 100644 --- a/backend/internal/handlers/auth.go +++ b/backend/internal/handlers/auth.go @@ -266,13 +266,17 @@ func (h *Handler) getRedirectFromCookie(r *http.Request, w http.ResponseWriter) } func (h *Handler) getRedirectUrl(r *http.Request) (string, error) { // Extract the redirect parameter from the request to get the site URL. - printHeaders(r) + siteURL := r.Header.Get("X-Forwarded-Uri") + if siteURL == "" { + siteURL = r.Header.Get("Referer") + } if siteURL == "" { siteURL = r.URL.Query().Get("redirect") - if siteURL == "" { - return "", fmt.Errorf("Redirect URL missing from both header and URL parameter") - } + } + if siteURL == "" { + printHeaders(r) + return "", fmt.Errorf("Redirect URL missing from both header and URL parameter") } return siteURL, nil }