401 doing listActiveSubscriptions on server side

Hey all im using svelte5 and better auth im trying to preload the subscription data in the +page.server.ts but im getting unauthorized when attempting to do so- when using the auth client it works fine?

export const load = async ({ request }) => {
    const session = await auth.api.getSession({
        headers: request.headers
    });

    if (!session) {
        console.log('no session');
        throw redirect(302, '/authenticate');
    }

    const data = await auth.api.listActiveSubscriptions();

    const activeSubscription = data?.find(
        (sub) => sub.status === 'active' || sub.status === 'trialing'
    );

    return { activeSubscription };
};
Was this page helpful?