Erratic Behavior with Environment Variables in Production on Vercel

Hi everyone,

I’m experiencing a strange issue with environment variables in my Vercel production environment. Sometimes, my app correctly accesses the environment variables configured for production. However, at other times, it either doesn’t access them or seems to be using environment variables from another environment

This is causing erratic behavior, such as receiving production users’ emails in my testing email account.

I’ve double-checked my configuration in the Vercel dashboard, and everything seems correct. Has anyone encountered similar issues or have suggestions on what might be causing this?

Thanks in advance for your help!

Hi @ltp-gestor, welcome to the Vercel Community! Thanks for posting your question here.

To help you debug this issue, can you share a few details about your project:

  • Which framework are you using? Next.js, Astro, Remix or any other.
  • Is there a specific environment variable that is having the issue?
  • Have you tried removing all the environment variables, re-adding them and then do a new deployment?

I’m here to debug this with you.

Hi @anshumanb, thanks.

I’m using a plain express app.

I’m having an issue with the environment variable that sets the environment behaviour, I mean the one that states if you are in “LOCAL”, “DEVELOPMENT” or “PROD”.

I tried redeploying and purging the cache. I did not try to remove all env vars and re-adding them.

Vercel supports a development environment for local development work, a preview environment for pre-production testing, and a production environment. The environment variables can be managed in project settings on Vercel.

Do you deploy the project with the automated GitHub integration, with Vercel CLI, or with a combination of methods? If you use the CLI to deploy from local or GitHub Actions, you should make sure you include the --prod option for production deployments and leave it off for preview deployments.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.