diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e8edee..5c5ae58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -255,14 +255,12 @@ jobs: run: pnpm test:e2e env: BROUTER_URL: http://localhost:17777 + # E2E=true is the explicit opt-out from the fail-loud + # requireSecret() / getDatabaseUrl() guards — playwright boots + # the server via `react-router serve` (NODE_ENV=production) but + # against the local dev Postgres + local cookie secrets. E2E: "true" INTEGRATION_SECRET: ${{ secrets.INTEGRATION_SECRET }} - # pnpm test:e2e starts the server via `react-router serve`, which - # boots with NODE_ENV=production. requireSecret() refuses to start - # in production without these set — supply random throwaway values - # for CI so the fail-loud guard still bites in real prod deploys. - JWT_SECRET: ci-jwt-secret-only-for-e2e-do-not-reuse - SESSION_SECRET: ci-session-secret-only-for-e2e-do-not-reuse - name: Playwright job summary if: ${{ !cancelled() }} diff --git a/apps/journal/app/lib/config.server.ts b/apps/journal/app/lib/config.server.ts index df7c5ed..c4222bc 100644 --- a/apps/journal/app/lib/config.server.ts +++ b/apps/journal/app/lib/config.server.ts @@ -18,7 +18,10 @@ export function getOrigin(): string { */ export function requireSecret(name: string, devFallback: string): string { const value = process.env[name]; - const isProd = process.env.NODE_ENV === "production"; + // Playwright runs `react-router serve` (NODE_ENV=production) against a + // local stack. E2E=true is the explicit opt-out so the guard still + // bites in real prod deploys. + const isProd = process.env.NODE_ENV === "production" && process.env.E2E !== "true"; if (isProd) { if (!value || value === devFallback) { throw new Error( diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index 2c6ee2b..bac4b53 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -15,7 +15,11 @@ const DEV_DB_URL = "postgres://trails:trails@localhost:5432/trails"; export function getDatabaseUrl(override?: string): string { if (override) return override; const url = process.env.DATABASE_URL; - if (process.env.NODE_ENV === "production") { + // Playwright runs `react-router serve` which boots with + // NODE_ENV=production, but the CI E2E suite legitimately points at a + // local Postgres using the dev URL. E2E=true is the explicit opt-out. + const isProd = process.env.NODE_ENV === "production" && process.env.E2E !== "true"; + if (isProd) { if (!url || url === DEV_DB_URL) { throw new Error( "Refusing to start: DATABASE_URL is unset or matches the dev default. " +