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.
|
: 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) {
|
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);
|
const isExpired = isTokenExpired(sessionData.session?.expires_at);
|
||||||
|
|
|
@ -16,17 +16,22 @@ export const Route = createFileRoute('/app')({
|
||||||
ssr: true,
|
ssr: true,
|
||||||
beforeLoad: async () => {
|
beforeLoad: async () => {
|
||||||
console.log('beforeLoad app route');
|
console.log('beforeLoad app route');
|
||||||
const { isExpired, accessToken = '' } = await getSupabaseSession();
|
try {
|
||||||
console.log('beforeLoad app route done');
|
const { isExpired, accessToken = '' } = await getSupabaseSession();
|
||||||
|
console.log('beforeLoad app route done');
|
||||||
|
|
||||||
if (isExpired || !accessToken) {
|
if (isExpired || !accessToken) {
|
||||||
console.error('Access token is expired or not found');
|
console.error('Access token is expired or not found');
|
||||||
|
throw redirect({ to: '/auth/login', replace: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
accessToken,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error in app route beforeLoad:', error);
|
||||||
throw redirect({ to: '/auth/login', replace: true });
|
throw redirect({ to: '/auth/login', replace: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
|
||||||
accessToken,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
loader: async ({ context }) => {
|
loader: async ({ context }) => {
|
||||||
const { queryClient, accessToken } = context;
|
const { queryClient, accessToken } = context;
|
||||||
|
|
Loading…
Reference in New Issue