summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2024-03-14 14:53:25 -0400
committerGravatar GitHub <noreply@github.com> 2024-03-14 14:53:25 -0400
commit098623c2616124bcc689e2409564dfda187f6688 (patch)
tree6fce66af773ede5f3f3fe7e07aecc25218083420
parent5166e9715a1ea18eb5c737ccf834c2ff446d253c (diff)
downloadastro-098623c2616124bcc689e2409564dfda187f6688.tar.gz
astro-098623c2616124bcc689e2409564dfda187f6688.tar.zst
astro-098623c2616124bcc689e2409564dfda187f6688.zip
Prefer getting app token from runtime env (#10445)
-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())});