Spaces:
Running
Running
Download apps/web/src/lib/auth-client.ts from Benaah/MicProtocol: direct link, hf CLI and curl.
- Browser
- Download file 876 Bytes
-
https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/apps/web/src/lib/auth-client.ts
- Command line
-
hf download hf://spaces/Benaah/MicProtocol/apps/web/src/lib/auth-client.ts
-
curl -L -o auth-client.ts https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/apps/web/src/lib/auth-client.ts
876 Bytes
| import { createAuthClient } from "better-auth/react"; | |
| import { jwtClient, inferAdditionalFields } from "better-auth/client/plugins"; | |
| import type { Auth } from "@micprotocol/api"; | |
| const BETTER_AUTH_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:4000"; | |
| /** | |
| * Better Auth client — mirrors the server's jwt plugin so the client | |
| * can request a JWT session token for the Authorization header, and | |
| * inferAdditionalFields keeps session types in sync with the server's | |
| * auth config type export. | |
| */ | |
| export const authClient = createAuthClient({ | |
| baseURL: BETTER_AUTH_URL, | |
| plugins: [ | |
| jwtClient(), | |
| inferAdditionalFields<Auth>(), | |
| ], | |
| fetchOptions: { | |
| // Always send cookies cross-origin (needed for subdomain routing) | |
| credentials: "include", | |
| }, | |
| }); | |
| export const { signIn, signUp, signOut, useSession } = authClient; | |