more auth ree
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
|||||||
Outlet,
|
Outlet,
|
||||||
Scripts,
|
Scripts,
|
||||||
createRootRouteWithContext,
|
createRootRouteWithContext,
|
||||||
|
redirect,
|
||||||
} from "@tanstack/react-router";
|
} from "@tanstack/react-router";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { DefaultCatchBoundary } from "@/components/DefaultCatchBoundary";
|
import { DefaultCatchBoundary } from "@/components/DefaultCatchBoundary";
|
||||||
@@ -132,6 +133,15 @@ export const Route = createRootRouteWithContext<{
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (error instanceof Response && error.status === 440) {
|
||||||
|
console.log('__root beforeLoad: Session needs refresh, redirecting');
|
||||||
|
const from = encodeURIComponent(location.pathname + location.search);
|
||||||
|
throw redirect({
|
||||||
|
to: "/refresh-session",
|
||||||
|
search: { redirect: from }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
console.error('__root beforeLoad error:', error);
|
console.error('__root beforeLoad error:', error);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ export async function ensureServerQueryData<TData>(
|
|||||||
if (error?.options?.to && error?.options?.statusCode) {
|
if (error?.options?.to && error?.options?.statusCode) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
if (error instanceof Response && error.status === 440) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ export const toServerResult = async <T>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (error instanceof Response && error.status === 440) {
|
||||||
|
logger.info('toServerResult: Re-throwing 440 Response for session refresh');
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
const duration = Date.now() - startTime;
|
const duration = Date.now() - startTime;
|
||||||
logger.error('Server Fn Error', error);
|
logger.error('Server Fn Error', error);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user