kaneo (minimalist kanban) fork to experiment adding a tangled integration
github.com/usekaneo/kaneo
1import { apiKeyClient } from "@better-auth/api-key/client";
2import {
3 anonymousClient,
4 deviceAuthorizationClient,
5 emailOTPClient,
6 genericOAuthClient,
7 inferAdditionalFields,
8 lastLoginMethodClient,
9 magicLinkClient,
10 organizationClient,
11} from "better-auth/client/plugins";
12import { createAuthClient } from "better-auth/react";
13import { ac, admin, member, owner } from "./permissions";
14
15const getBaseURL = () => {
16 const apiUrl = import.meta.env.VITE_API_URL || "http://localhost:1337";
17 try {
18 const url = new URL(apiUrl);
19 return `${url.protocol}//${url.host}`;
20 } catch {
21 return apiUrl.split("/").slice(0, 3).join("/");
22 }
23};
24
25export const authClient = createAuthClient({
26 baseURL: getBaseURL(),
27 basePath: "/api/auth",
28 plugins: [
29 anonymousClient(),
30 lastLoginMethodClient(),
31 magicLinkClient(),
32 emailOTPClient(),
33 organizationClient({
34 ac,
35 roles: {
36 member,
37 admin,
38 owner,
39 },
40 }),
41 genericOAuthClient(),
42 deviceAuthorizationClient(),
43 apiKeyClient(),
44 inferAdditionalFields({
45 user: {
46 locale: {
47 type: "string",
48 required: false,
49 input: true,
50 },
51 },
52 }),
53 ],
54});