mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
add cloudflare workers support (#326)
This commit is contained in:
@@ -14,21 +14,22 @@ export const auth = betterAuth({
|
||||
{{#if (eq database "mongodb")}}provider: "mongodb"{{/if}}
|
||||
}),
|
||||
trustedOrigins: [
|
||||
process.env.CORS_ORIGIN || "",{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
"my-better-t-app://",{{/if}}
|
||||
process.env.CORS_ORIGIN || "",
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
"my-better-t-app://",
|
||||
{{/if}}
|
||||
],
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
}
|
||||
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
,
|
||||
plugins: [expo()]
|
||||
, plugins: [expo()]
|
||||
{{/if}}
|
||||
});
|
||||
{{/if}}
|
||||
|
||||
{{#if (eq orm "drizzle")}}
|
||||
{{#if (or (eq runtime "bun") (eq runtime "node"))}}
|
||||
import { betterAuth } from "better-auth";
|
||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
@@ -45,20 +46,52 @@ export const auth = betterAuth({
|
||||
schema: schema,
|
||||
}),
|
||||
trustedOrigins: [
|
||||
process.env.CORS_ORIGIN || "",{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
"my-better-t-app://",{{/if}}
|
||||
process.env.CORS_ORIGIN || "",
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
"my-better-t-app://",
|
||||
{{/if}}
|
||||
],
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
}
|
||||
|
||||
},
|
||||
secret: process.env.BETTER_AUTH_SECRET,
|
||||
baseURL: process.env.BETTER_AUTH_URL,
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
,
|
||||
plugins: [expo()]
|
||||
plugins: [expo()],
|
||||
{{/if}}
|
||||
});
|
||||
{{/if}}
|
||||
|
||||
{{#if (eq runtime "workers")}}
|
||||
import { betterAuth } from "better-auth";
|
||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
import { expo } from "@better-auth/expo";
|
||||
{{/if}}
|
||||
import { db } from "@/db";
|
||||
import * as schema from "../db/schema/auth";
|
||||
import { env } from "cloudflare:workers";
|
||||
|
||||
export const auth = betterAuth({
|
||||
database: drizzleAdapter(db, {
|
||||
{{#if (eq database "postgres")}}provider: "pg",{{/if}}
|
||||
{{#if (eq database "sqlite")}}provider: "sqlite",{{/if}}
|
||||
{{#if (eq database "mysql")}}provider: "mysql",{{/if}}
|
||||
schema: schema,
|
||||
}),
|
||||
trustedOrigins: [env.CORS_ORIGIN],
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
},
|
||||
secret: env.BETTER_AUTH_SECRET,
|
||||
baseURL: env.BETTER_AUTH_URL,
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
plugins: [expo()],
|
||||
{{/if}}
|
||||
});
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{#if (eq orm "mongoose")}}
|
||||
import { betterAuth } from "better-auth";
|
||||
import { mongodbAdapter } from "better-auth/adapters/mongodb";
|
||||
@@ -70,16 +103,16 @@ import { client } from "../db";
|
||||
export const auth = betterAuth({
|
||||
database: mongodbAdapter(client),
|
||||
trustedOrigins: [
|
||||
process.env.CORS_ORIGIN || "",{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
"my-better-t-app://",{{/if}}
|
||||
process.env.CORS_ORIGIN || "",
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
"my-better-t-app://",
|
||||
{{/if}}
|
||||
],
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
}
|
||||
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
,
|
||||
plugins: [expo()]
|
||||
, plugins: [expo()]
|
||||
{{/if}}
|
||||
});
|
||||
{{/if}}
|
||||
@@ -93,16 +126,16 @@ import { expo } from "@better-auth/expo";
|
||||
export const auth = betterAuth({
|
||||
database: "", // Invalid configuration
|
||||
trustedOrigins: [
|
||||
process.env.CORS_ORIGIN || "",{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
"my-better-t-app://",{{/if}}
|
||||
process.env.CORS_ORIGIN || "",
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
"my-better-t-app://",
|
||||
{{/if}}
|
||||
],
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
}
|
||||
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
,
|
||||
plugins: [expo()]
|
||||
, plugins: [expo()]
|
||||
{{/if}}
|
||||
});
|
||||
{{/if}}
|
||||
|
||||
Reference in New Issue
Block a user