mirror of https://github.com/buster-so/buster.git
add additional loggin
This commit is contained in:
parent
430ae8d35a
commit
48c65db3c9
|
@ -14,7 +14,11 @@ export const getSupabaseSession = async () => {
|
|||
: await supabase.auth.getSession(); //10 - 15ms locally, maybe consider getting it from the cookie instead. console the supabase object it had it there.
|
||||
|
||||
if ((!sessionData?.session || sessionError) && !isServer) {
|
||||
throw new Error('No session data found');
|
||||
return {
|
||||
accessToken: '',
|
||||
isExpired: true,
|
||||
expiresAt: 0,
|
||||
};
|
||||
}
|
||||
|
||||
const isExpired = isTokenExpired(sessionData.session?.expires_at);
|
||||
|
|
|
@ -16,6 +16,7 @@ export const Route = createFileRoute('/app')({
|
|||
ssr: true,
|
||||
beforeLoad: async () => {
|
||||
console.log('beforeLoad app route');
|
||||
try {
|
||||
const { isExpired, accessToken = '' } = await getSupabaseSession();
|
||||
console.log('beforeLoad app route done');
|
||||
|
||||
|
@ -27,6 +28,10 @@ export const Route = createFileRoute('/app')({
|
|||
return {
|
||||
accessToken,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error in app route beforeLoad:', error);
|
||||
throw redirect({ to: '/auth/login', replace: true });
|
||||
}
|
||||
},
|
||||
loader: async ({ context }) => {
|
||||
const { queryClient, accessToken } = context;
|
||||
|
|
Loading…
Reference in New Issue