summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/dry-rivers-switch.md5
-rw-r--r--packages/db/src/core/integration/vite-plugin-db.ts2
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/dry-rivers-switch.md b/.changeset/dry-rivers-switch.md
new file mode 100644
index 000000000..bcefabb10
--- /dev/null
+++ b/.changeset/dry-rivers-switch.md
@@ -0,0 +1,5 @@
+---
+"@astrojs/db": patch
+---
+
+Prefer getting the app token from the runtime env
diff --git a/packages/db/src/core/integration/vite-plugin-db.ts b/packages/db/src/core/integration/vite-plugin-db.ts
index aae9094ca..1a6c9b50b 100644
--- a/packages/db/src/core/integration/vite-plugin-db.ts
+++ b/packages/db/src/core/integration/vite-plugin-db.ts
@@ -142,7 +142,7 @@ export function getStudioVirtualModContents({
return `
import {asDrizzleTable, createRemoteDatabaseClient} from ${RUNTIME_IMPORT};
-export const db = await createRemoteDatabaseClient(${JSON.stringify(
+export const db = await createRemoteDatabaseClient(process.env.ASTRO_STUDIO_APP_TOKEN ?? ${JSON.stringify(
appToken
// Respect runtime env for user overrides in SSR
)}, import.meta.env.ASTRO_STUDIO_REMOTE_DB_URL ?? ${JSON.stringify(getRemoteDatabaseUrl())});