diff --git a/public/app/routes/routes.tsx b/public/app/routes/routes.tsx index 41200ebf56b..dd1a0a4967a 100644 --- a/public/app/routes/routes.tsx +++ b/public/app/routes/routes.tsx @@ -1,4 +1,5 @@ -import { Navigate, useParams } from 'react-router-dom-v5-compat'; +import { useEffect } from 'react'; +import { Navigate, useLocation, useParams } from 'react-router-dom-v5-compat'; import { isTruthy } from '@grafana/data'; import { NavLandingPage } from 'app/core/components/NavLandingPage/NavLandingPage'; @@ -534,6 +535,10 @@ export function getAppRoutes(): RouteDescriptor[] { ...extraRoutes, ...getPublicDashboardRoutes(), ...getDataConnectionsRoutes(), + { + path: '/goto/*', + component: HandleGoToRedirect, + }, { path: '/*', component: PageNotFound, @@ -571,3 +576,14 @@ function DataSourceEditRoute() { const { uid = '' } = useParams(); return ; } + +// Explicitly send "goto" URLs to server, bypassing client-side routing +function HandleGoToRedirect() { + const { pathname } = useLocation(); + + useEffect(() => { + window.location.href = pathname; + }, [pathname]); + + return null; +}