mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-26 09:54:43 +10:00
50ba37a27f
* chore(release): v5.1.0 * feat: implement resume thumbnails * fix: remove unused mcp tools * docs: fix formatting of docs
26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
// Isomorphic getSession.
|
|
// On the server, calls Better Auth's server API directly (uses request headers).
|
|
// On the client, calls the auth client's getSession over fetch.
|
|
//
|
|
// This lives in apps/web (not @reactive-resume/auth) because @reactive-resume/auth
|
|
// is server-only — importing its `auth` instance into client code drags in
|
|
// drizzle/pg/jose and triggers TanStack Start's client/server import-protection
|
|
// (the "tanstack-start-injected-head-scripts" virtual-module error).
|
|
|
|
import type { AuthSession } from "@reactive-resume/auth/types";
|
|
import { createIsomorphicFn } from "@tanstack/react-start";
|
|
import { getRequestHeaders } from "@tanstack/react-start/server";
|
|
import { auth } from "@reactive-resume/auth/config";
|
|
import { authClient } from "./client";
|
|
|
|
export const getSession = createIsomorphicFn()
|
|
.client(async (): Promise<AuthSession | null> => {
|
|
const { data, error } = await authClient.getSession();
|
|
if (error) return null;
|
|
return data as AuthSession;
|
|
})
|
|
.server(async (): Promise<AuthSession | null> => {
|
|
const result = await auth.api.getSession({ headers: getRequestHeaders() });
|
|
return result as AuthSession | null;
|
|
});
|