TanStackT
TanStack3mo ago
2 replies
verbal-lime

How to currently access request headers?

I see some old suggestions linking to a page in server functions that no longer exists.
https://tanstack.com/start/latest/docs/framework/react/server-functions#accessing-the-request-context

SSR is causing issues with better-auth and i was attempting to create an isomorphic function that would correctly fetch the user's session like so:

export const getSession = createIsomorphicFn()
  .server(async () => {
    const session = await auth.api.getSession({ 
      headers: NEED_HEADERS_HERE 
    });
    return session;
  })
  .client(async () => {
    const session = await authClient.getSession();
    return session;
  });
Was this page helpful?