From 59cc00b07eee540b98452a98cf2869635b334a47 Mon Sep 17 00:00:00 2001 From: "grafana-delivery-bot[bot]" <132647405+grafana-delivery-bot[bot]@users.noreply.github.com> Date: Mon, 15 Sep 2025 16:39:21 +0200 Subject: [PATCH] [release-12.2.1] Fix: Fix redirection after login when Grafana is served from subpath (#111069) Fix: Fix redirection after login when Grafana is served from subpath (#110889) Fix short link (/goto) redirection when Grafana is served from subpath (cherry picked from commit ccc87a03f0ec70eb28f9ce49221834718abeca7d) Co-authored-by: Misi --- public/app/app.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/public/app/app.ts b/public/app/app.ts index 05f6a2e0ab0..8269bb6a2d7 100644 --- a/public/app/app.ts +++ b/public/app/app.ts @@ -472,14 +472,18 @@ function handleRedirectTo(): void { } window.sessionStorage.removeItem(RedirectToUrlKey); - const decodedRedirectTo = decodeURIComponent(redirectTo); + let decodedRedirectTo = decodeURIComponent(redirectTo); if (decodedRedirectTo.startsWith('/goto/')) { // In this case there should be a request to the backend + if (config.appSubUrl && !decodedRedirectTo.startsWith(config.appSubUrl)) { + decodedRedirectTo = config.appSubUrl + decodedRedirectTo; + } window.location.replace(decodedRedirectTo); - } else { - const stripped = locationUtil.stripBaseFromUrl(decodedRedirectTo); - locationService.replace(stripped); + return; } + // Ensure that the appsuburl is stripped from the redirect to in case of a frontend redirect + const stripped = locationUtil.stripBaseFromUrl(decodedRedirectTo); + locationService.replace(stripped); } export default new GrafanaApp();