1 Commits

Author SHA1 Message Date
6893ca6ba9 fix(web): lazy-parse env so docker build doesn't crash on missing DATABASE_URL
`scripts/publish.sh` failed during the web image build at
"Collecting page data" with:
  ZodError: DATABASE_URL: Required

next build walks every route module including api/events/route.ts,
which imports env from @/env. The previous shape ran
envSchema.parse(process.env) at module top level, so the parse fired
inside the build container where DATABASE_URL deliberately isn't set.

Wrap the parse in a Proxy that resolves on first property access.
The build's page-data pass doesn't read any env property, so the
parse never runs at build time. Runtime callers (db.ts, media.ts,
api/events/route.ts) hit the proxy on first use and get the same
strict Zod validation as before.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 22:13:30 +08:00