Next.js Discord

Discord Forum

NEXT_PUBLIC_ env vars not exposed to client with production build!?

Asian black bear posted this in #help-forum
Open in Discord
Asian black bearOP
I've been chasing this problem for 12+ hours, trying to debug. Happens on local and Vercel. NEXT_PUBLIC_APP is my current server base url for use with RTK Query, but the value is undefined on client. I thought NEXT_PUBLIC_ env vars were exposed to the client. Is this a bug? Is there some magic configuration I'm missing? I've heard about NEXT_PUBLIC_VERCEL_URL... is that generated by Vercel on production/preview and defaults to localhost on local production instance? This is beyond frustrating. Help.

0 Replies