Add Better Auth admin authentication
This commit is contained in:
31
convex/betterAuth/env.ts
Normal file
31
convex/betterAuth/env.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
type BetterAuthEnv = Record<string, string | undefined>;
|
||||
const schemaGenerationSecret = "convex-better-auth-schema-generation-secret";
|
||||
|
||||
export function getBetterAuthServerConfig(
|
||||
env: BetterAuthEnv,
|
||||
options: { allowMissingSecret?: boolean } = {},
|
||||
) {
|
||||
const secret = env.BETTER_AUTH_SECRET?.trim();
|
||||
|
||||
if (!secret) {
|
||||
if (options.allowMissingSecret) {
|
||||
return {
|
||||
appUrl:
|
||||
env.BETTER_AUTH_URL?.trim() ||
|
||||
env.NEXT_PUBLIC_APP_URL?.trim() ||
|
||||
"http://localhost:3000",
|
||||
secret: schemaGenerationSecret,
|
||||
};
|
||||
}
|
||||
|
||||
throw new Error("Missing BETTER_AUTH_SECRET in the environment.");
|
||||
}
|
||||
|
||||
return {
|
||||
appUrl:
|
||||
env.BETTER_AUTH_URL?.trim() ||
|
||||
env.NEXT_PUBLIC_APP_URL?.trim() ||
|
||||
"http://localhost:3000",
|
||||
secret,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user