You added the env variable in the Vercel dashboard but it's still undefined in your function. This is almost always a redeploy requirement or environment scope mismatch — not a Vercel bug.
Vercel bakes environment variables into the build at deploy time. Adding a variable in the dashboard does NOT update a live deployment. You must trigger a new deployment after adding or changing env vars. Go to Deployments > Redeploy, or push a new commit to trigger a build.
Vercel has three environments: Production, Preview, and Development. A variable set for 'Preview' is not available in 'Production' deployments. Check your variable's environment scope in Settings > Environment Variables and ensure it's set for the environment you're deploying to.
Environment variable names are case-sensitive. NEXT_PUBLIC_API_KEY and next_public_api_key are different variables. Copy-paste the exact name from your code and the dashboard side-by-side to verify they match character for character.
In Next.js on Vercel, variables available in the browser must be prefixed with NEXT_PUBLIC_. Without this prefix, the variable is only available server-side. If your client code is reading undefined, check whether you need the prefix.
If your repository has a .env or .env.production file committed, its values override Vercel dashboard settings during build. Check your repo for .env files and ensure they don't contain conflicting or empty values for the variable you're trying to set.
Real operator. No ticket queue. San Diego-based. Most issues resolved in one thread.
Related problems in this cluster: