Next.js Discord

Discord Forum

How do I make .env.local variables work in final deployments?

Answered
Minskin posted this in #help-forum
Open in Discord
MinskinOP
Hi everyone! Iam using this API called "Next Cloudinary" that requires me to specify a cloud name inside my .env.local file. It looks something like this:
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME="cloudname"

I couldn't find a .env.local file anywhere, so I just created it and did what I explained above. It worked for me flawlesly when running in dev, but when I went to deploy my website on Vercel, it crashed and gave me the error that I need to specify a cloud name. My guess is that .env.local only works locally, but im a newbie to next.js and don't really know how to get it to work aside from dev. I also think that im supposed to keep the name secret. How would I go about this?
Answered by joulev
Go to project settings > environment variables > add your env var there
View full answer

9 Replies

Answer
Then redeploy
@joulev Go to project settings > environment variables > add your env var there
MinskinOP
It warns me that doing "NEXT_PUBLIC" will expose it to everyone
Correct
MinskinOP
Not sure if it is supposed to exposed
but I tried without just now and it doesnt work
@Minskin Not sure if it is supposed to exposed
It may be exposed, don’t worry
MinskinOP
Alright, thanks
@joulev Everything works now. Thanks once again :)