[release-11.5.9] Fix: Fix redirection after login when Grafana is served from subpath (#111099)

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 ccc87a03f0)
This commit is contained in:
Misi
2025-09-16 09:31:35 +02:00
committed by GitHub
parent b3e2dc3763
commit 12dc5dcaaf
+8 -3
View File
@@ -425,13 +425,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 {
locationService.replace(decodedRedirectTo);
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();