Tech
"Invalid API key" or undefined env vars on Vercel: how to fix it
Your app works on your machine. You deploy to Vercel and get one of these:
Error: supabaseUrl is required.
AuthApiError: Invalid API key
OpenAI API error: 401 Incorrect API key provided: undefined
Or process.env.MY_KEY is simply undefined in production.
Why it happens
.env.local is not deployed (it's git-ignored, as it should be). Vercel needs its own copy.
The variable was added after the last deployment. Env vars only apply to new deployments.
It ...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to