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:

  1. Initialize a next-forge project: bun x next-forge@latest init
  2. Copy .env.example to .env.local across packages/apps.
  3. Fill only the required variables (like DATABASE_URL and CLERK_SECRET_KEY) leaving optional ones as "" (the default in .env.example).
  4. Run bun run dev.
  5. 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