ENV vars work locally, not in production

A practical fix and a copyable AI coding prompt. Replace bracketed placeholders with your project details.

1. Check the problem

Three gotchas: client vars need the `NEXT_PUBLIC_` prefix, preview and production are separate scopes so set the var in both, and a bad hot reload can skip re-reading env vars, redeploy clean to fix it.

2. Use the prompt

My env vars work locally but not in production on Vercel. Check the three usual gotchas against my code: a missing NEXT_PUBLIC_ prefix for client-side vars, the var not set in both Preview and Production scopes, and stale runtime reads needing a clean redeploy. Tell me which apply and the exact fix.

3. Verify the fix

Review the proposed diff, run the relevant checks and exercise the original failing flow before merging.

Continue in the related workflow chapter.