diff --git a/packages/web-main/src/routes/_auth.tsx b/packages/web-main/src/routes/_auth.tsx index 2529c7a021..76b7f3213d 100644 --- a/packages/web-main/src/routes/_auth.tsx +++ b/packages/web-main/src/routes/_auth.tsx @@ -7,7 +7,7 @@ export const Route = createFileRoute('/_auth')({ const session = await context.auth.getSession(); if (!session) { const redirectPath = location.pathname === '/login' ? '/' : location.pathname; - throw redirect({ to: '/login', search: { redirect: redirectPath } }); + throw redirect({ to: '/login', search: { redirect: redirectPath }, replace: true }); } }, loader: async ({ context }) => { diff --git a/packages/web-main/src/routes/_auth/_global.tsx b/packages/web-main/src/routes/_auth/_global.tsx index eab7804bcb..a9030716cb 100644 --- a/packages/web-main/src/routes/_auth/_global.tsx +++ b/packages/web-main/src/routes/_auth/_global.tsx @@ -14,7 +14,11 @@ export const Route = createFileRoute('/_auth/_global')({ if (location.pathname == '/' && !canManageGameServers) { const gameservers = await context.queryClient.ensureQueryData(gameServersQueryOptions()); if (gameservers.data.length > 0) { - throw redirect({ to: '/gameserver/$gameServerId/shop', params: { gameServerId: gameservers.data[0].id } }); + throw redirect({ + to: '/gameserver/$gameServerId/shop', + params: { gameServerId: gameservers.data[0].id }, + replace: true, + }); } } }, diff --git a/packages/web-main/src/routes/_auth/_global/index.tsx b/packages/web-main/src/routes/_auth/_global/index.tsx index d32991239b..9b5a9e923d 100644 --- a/packages/web-main/src/routes/_auth/_global/index.tsx +++ b/packages/web-main/src/routes/_auth/_global/index.tsx @@ -8,7 +8,7 @@ export const Route = createFileRoute('/_auth/_global/')({ beforeLoad: async ({ context }) => { const session = await context.queryClient.ensureQueryData(userMeQueryOptions()); if (hasPermission(session, [PERMISSIONS.ReadEvents])) { - throw redirect({ to: '/dashboard' }); + throw redirect({ to: '/dashboard', replace: true }); } /* if user has no permissions at all, so can't see any page, redirect to forbidden */ diff --git a/packages/web-main/src/routes/_auth/_global/player.$playerId/index.tsx b/packages/web-main/src/routes/_auth/_global/player.$playerId/index.tsx index 358cfd381f..d2e215408c 100644 --- a/packages/web-main/src/routes/_auth/_global/player.$playerId/index.tsx +++ b/packages/web-main/src/routes/_auth/_global/player.$playerId/index.tsx @@ -1,7 +1,7 @@ -import { createFileRoute } from '@tanstack/react-router'; +import { createFileRoute, redirect } from '@tanstack/react-router'; export const Route = createFileRoute('/_auth/_global/player/$playerId/')({ - beforeLoad: ({ navigate, params }) => { - navigate({ to: '/player/$playerId/info', params: { playerId: params.playerId } }); + beforeLoad: ({ params }) => { + throw redirect({ to: '/player/$playerId/info', params: { playerId: params.playerId }, replace: true }); }, }); diff --git a/packages/web-main/src/routes/_auth/_global/settings/index.tsx b/packages/web-main/src/routes/_auth/_global/settings/index.tsx index 81c1376526..3ca1d5307e 100644 --- a/packages/web-main/src/routes/_auth/_global/settings/index.tsx +++ b/packages/web-main/src/routes/_auth/_global/settings/index.tsx @@ -1,7 +1,7 @@ -import { createFileRoute } from '@tanstack/react-router'; +import { createFileRoute, redirect } from '@tanstack/react-router'; export const Route = createFileRoute('/_auth/_global/settings/')({ - beforeLoad: ({ navigate }) => { - navigate({ to: '/settings/gameservers' }); + beforeLoad: () => { + throw redirect({ to: '/settings/gameservers', replace: true }); }, });