Environment Variables in Production
Unanswered
Golden paper wasp posted this in #help-forum
Golden paper waspOP
Hi, I have some environment variables in the .env.local file. They are like
CLIENT_EMAIL= etc. Now when I add them in the environment variable settings in Vercel, the api route doesn't work. I tried prefixing them with NEXT_PUBLIC but that didn't work either. Any help / advice? Thanks17 Replies
Asiatic Lion
Hello
Please DM me
I m familiar with Next project development and deployment on Vercel env
@Golden paper wasp Hi, I have some environment variables in the .env.local file. They are like `CLIENT_EMAIL=` etc. Now when I add them in the environment variable settings in Vercel, the api route doesn't work. I tried prefixing them with `NEXT_PUBLIC` but that didn't work either. Any help / advice? Thanks
have you redeploy after adding the variable?
btw, use
btw, use
CLIENT_EMAIL for api route@Asiatic Lion Please DM me
Why are you asking people to DM you for help?
Asiatic Lion
?
I m not asking help.
I m not here to get help from anyone
@Ray have you redeploy after adding the variable?
btw, use `CLIENT_EMAIL` for api route
Golden paper waspOP
yes I have done redeploys since adding the environment variables to Vercel. The route iteslf is in a route.js file in an api folder. Everything about it works fine when the actual values are in the file, but it's broken for some reason with the values in the .env
@Asiatic Lion I m familiar with Next project development and deployment on Vercel env
Golden paper waspOP
Thanks I'll message you
Yellowstripe scad
don’t know much about next, or vercel so prolly not much help but that’s really odd. this might be something competely different but i know you can link your vercel project to your dir and then generate a .env for development somehow
i can’t tell you how or what i just think this exists, prolly doesn’t help
Golden paper waspOP
@Yellowstripe scad no worries
Russian Blue
I cannot get the variables from env to work either. The strange thing is that they work in local dev as if the env doesn't contain anything. Console logging the object returns an empty object and for specific variables 'undefined'.
@Golden paper wasp have you figured it out?
@Russian Blue <@333185480021639169> have you figured it out?
Golden paper waspOP
yes I did. I think it was that I forgot to prefix the environment variables with NEXT_PUBLIC in the api/route.js file as well
Russian Blue
For me, it was an issue with calling the .env inside a client component... rookie mistake...