fix: empty optional environment variables fail Zod validation
Author: Victory-7291Created Aug 15, 2026Updated Aug 15, 2026
Describe the bug
When creating a new project from the template and copying .env.example to .env.local, optional environment variables that are left as empty strings (e.g. BETTERSTACK_URL="", RESEND_FROM="", CLERK_WEBHOOK_SECRET="", ARCJET_KEY="", etc.) fail Zod schema validation on bun run dev with errors like Invalid URL, Invalid email address, or must start with "...".
next-forge version I am using version 6.0.2
To Reproduce Steps to reproduce the behavior:
- Initialize a next-forge project:
bun x next-forge@latest init - Copy
.env.exampleto.env.localacross packages/apps. - Fill only the required variables (like
DATABASE_URLandCLERK_SECRET_KEY) leaving optional ones as""(the default in.env.example). - Run
bun run dev. - Observe Zod validation failures on apps (
app,web,api).
Expected behavior
Optional environment variables defined as empty strings in .env files should be treated as undefined and pass validation when not configured.
Desktop (please complete the following information):
- OS: macOS
Source: vercel/next-forge