diff --git a/.changeset/modern-roses-buy.md b/.changeset/modern-roses-buy.md new file mode 100644 index 000000000000..db705b573902 --- /dev/null +++ b/.changeset/modern-roses-buy.md @@ -0,0 +1,5 @@ +--- +"@astrojs/db": patch +--- + +Fix accessing remote database URL diff --git a/packages/db/src/core/integration/vite-plugin-db.ts b/packages/db/src/core/integration/vite-plugin-db.ts index 7e54190ea38f..1a6c9b50b780 100644 --- a/packages/db/src/core/integration/vite-plugin-db.ts +++ b/packages/db/src/core/integration/vite-plugin-db.ts @@ -142,7 +142,10 @@ export function getStudioVirtualModContents({ return ` import {asDrizzleTable, createRemoteDatabaseClient} from ${RUNTIME_IMPORT}; -export const db = await createRemoteDatabaseClient(process.env.ASTRO_STUDIO_APP_TOKEN); +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())}); export * from ${RUNTIME_CONFIG_IMPORT};