mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Routing: Explicitly handle goto redirects (#95559)
This commit is contained in:
parent
85ee91aa77
commit
f3bdf4455c
@ -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 <Navigate replace to={CONNECTIONS_ROUTES.DataSourcesEdit.replace(':uid', uid)} />;
|
||||
}
|
||||
|
||||
// Explicitly send "goto" URLs to server, bypassing client-side routing
|
||||
function HandleGoToRedirect() {
|
||||
const { pathname } = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
window.location.href = pathname;
|
||||
}, [pathname]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user