From 04596cf547b9e134c011ae7bb605a0276929ecdf Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Thu, 25 Sep 2025 15:36:07 -0600 Subject: [PATCH] updated the embed axios handler --- apps/web/src/api/buster_rest/chats/queryRequests.ts | 1 - apps/web/src/api/createAxiosInstance.ts | 7 ++++--- apps/web/src/routes/embed.tsx | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/web/src/api/buster_rest/chats/queryRequests.ts b/apps/web/src/api/buster_rest/chats/queryRequests.ts index d792b4689..49ba1dddb 100644 --- a/apps/web/src/api/buster_rest/chats/queryRequests.ts +++ b/apps/web/src/api/buster_rest/chats/queryRequests.ts @@ -431,7 +431,6 @@ export const useUpdateChatShare = () => { } if (variables.params.workspace_sharing !== undefined) { draft.workspace_sharing = variables.params.workspace_sharing; - s; } }); }); diff --git a/apps/web/src/api/createAxiosInstance.ts b/apps/web/src/api/createAxiosInstance.ts index a4cb571ef..e3d69827f 100644 --- a/apps/web/src/api/createAxiosInstance.ts +++ b/apps/web/src/api/createAxiosInstance.ts @@ -50,9 +50,10 @@ export const defaultAxiosRequestHandler = async (config: InternalAxiosRequestCon const { accessToken: token } = session; if (!token) { - console.warn('No token found'); - window.location.href = AuthRoute.to; - return Promise.reject(new Error('No token found')); + console.warn('No token found', config); + //embed route were having an issue with this... + //window.location.href = AuthRoute.to; + //return Promise.reject(new Error('No token found')); } (config.headers as AxiosRequestHeaders).Authorization = `Bearer ${token}`; diff --git a/apps/web/src/routes/embed.tsx b/apps/web/src/routes/embed.tsx index 844f6ea93..f50011105 100644 --- a/apps/web/src/routes/embed.tsx +++ b/apps/web/src/routes/embed.tsx @@ -1,13 +1,15 @@ import type { AssetType } from '@buster/server-shared/assets'; import { createFileRoute, Outlet, type RouteContext } from '@tanstack/react-router'; import { prefetchGetMyUserInfo } from '@/api/buster_rest/users'; +import { getSupabaseSession } from '@/integrations/supabase/getSupabaseUserClient'; import { signInWithAnonymousUser } from '@/integrations/supabase/signIn'; import { AppAssetCheckLayout } from '@/layouts/AppAssetCheckLayout'; export const Route = createFileRoute('/embed')({ beforeLoad: async ({ context, matches }) => { - const user = await prefetchGetMyUserInfo(context.queryClient); - if (!user) await signInWithAnonymousUser(); //we fallback to an anonymous user + const token = await getSupabaseSession(); + if (token.accessToken) await prefetchGetMyUserInfo(context.queryClient); + else await signInWithAnonymousUser(); //we fallback to an anonymous user const assetType = [...matches].reverse().find(({ staticData }) => staticData?.assetType) ?.staticData?.assetType as AssetType;