#NEXTJS 12 + RAILWAY - Env vars in browser are undefined!

5 messages · Page 1 of 1 (latest)

rapid lynx
#

Hey guys, I have an .env.local with NEXT_PUBLIC_API_URL and It works fine in local. But when I deploy in railway and I add the variable in railway just like in local file it returns undefined..

#

Just asking in case someone already struggled with this aswell

ivory tapir
#

I think .env.local gets overridden by .env or .env.production when it's a production build.

Do you also have a .env file

rapid lynx
#

I have an .env.dev

#

But I am adding the env vars on railway with the exact name as I have in .env.local