Merge pull request #1155 from buster-so/big-nate-bus-1947-public-url-is-requiring-me-to-log-in-to-view-it

updated the embed axios handler
This commit is contained in:
Nate Kelley 2025-09-25 15:37:32 -06:00 committed by GitHub
commit 468511d8cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 6 deletions

View File

@ -431,7 +431,6 @@ export const useUpdateChatShare = () => {
}
if (variables.params.workspace_sharing !== undefined) {
draft.workspace_sharing = variables.params.workspace_sharing;
s;
}
});
});

View File

@ -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}`;

View File

@ -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;