Next.js Discord

Discord Forum

env varaiables not working in vercel

Unanswered
Peterbald posted this in #help-forum
Open in Discord
PeterbaldOP
In my nextjs app, the environment variables work only in client components, but not in server components and server actions. Note that the variables work when I run the build task locally, but not when I host on vercel.

const url = ${process.env.NEXT_PUBLIC_BACK_URL}/conversations; when called in server components doesnot read the env variable. How to solve this?

2 Replies

Asian black bear
Did you define the variables in the Vercel UI?
PeterbaldOP
yes