Next.js Discord

Discord Forum

.env variables working on localhost but not on deploy

Unanswered
Alligator mississippiensis posted this in #help-forum
Open in Discord
Alligator mississippiensisOP
I've been trying to set .env file on the vercel website, on localhost the variables work fine, but the moment i pass them to vercel they dont get recognized and it shows on the console as /undefined:

localhost .env:

NEXT_PUBLIC_API_REGISTER_USER = "http://localhost:3000/api/register-user"


and when i set them up on vercel .env i change it to:

key = NEXT_PUBLIC_API_REGISTER_USER 
value = https://www.nameofthehost.com/api/register-user


just to add that i'm trying to fetch from my own api, which is also set up in nextjs.

thanks!

0 Replies