Skip to content

Commit 3bba3f3

Browse files
fix(cli): add dotenv in db package when combined with next
1 parent 74d2744 commit 3bba3f3

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

apps/cli/src/utils/better-auth-plugin-setup.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export async function setupBetterAuthPlugins(
2626
);
2727
}
2828

29+
if (config.backend === "self" && config.frontend?.includes("next")) {
30+
pluginsToAdd.push("nextCookies()");
31+
importsToAdd.push('import { nextCookies } from "better-auth/next-js";');
32+
}
33+
2934
if (
3035
config.frontend?.includes("native-nativewind") ||
3136
config.frontend?.includes("native-unistyles")

apps/cli/templates/db/drizzle/mysql/src/index.ts.hbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
{{#if (or (eq runtime "bun") (eq runtime "node") (eq runtime "none"))}}
2+
{{#if (and (ne backend "self") (includes frontend "next"))}}
3+
import dotenv from "dotenv";
4+
5+
dotenv.config({
6+
path: "../../apps/server/.env",
7+
});
8+
9+
{{/if}}
210
{{#if (eq dbSetup "planetscale")}}
311
import { drizzle } from "drizzle-orm/planetscale-serverless";
412

apps/cli/templates/db/drizzle/postgres/src/index.ts.hbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
{{#if (or (eq runtime "bun") (eq runtime "node") (eq runtime "none"))}}
2+
{{#if (and (ne backend "self") (includes frontend "next"))}}
3+
import dotenv from "dotenv";
4+
5+
dotenv.config({
6+
path: "../../apps/server/.env",
7+
});
8+
9+
{{/if}}
210
{{#if (eq dbSetup "neon")}}
311
import { neon, neonConfig } from '@neondatabase/serverless';
412
import { drizzle } from 'drizzle-orm/neon-http';

apps/cli/templates/db/drizzle/sqlite/src/index.ts.hbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
{{#if (or (eq runtime "bun") (eq runtime "node") (eq runtime "none"))}}
2+
{{#if (and (ne backend "self") (includes frontend "next"))}}
3+
import dotenv from "dotenv";
4+
5+
dotenv.config({
6+
path: "../../apps/server/.env",
7+
});
8+
9+
{{/if}}
210
import { drizzle } from "drizzle-orm/libsql";
311
import { createClient } from "@libsql/client";
412

0 commit comments

Comments
 (0)