[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 ccc87a03f0)

Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>
This commit is contained in:
grafana-delivery-bot[bot] 2025-09-15 16:39:21 +02:00 committed by GitHub
parent 8ce2c2d3eb
commit 59cc00b07e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 4 deletions

View File

@ -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();