Process.env variable is undefined during
npm run build
(next 14)

Anonymous
PROOP

a month ago

During build time, getting error that process.env.API_URL is undefined.
It's next.js 14 project. (deployment id: ac5aa2a6-23ad-4d92-a6ff-91de1640b8ef)

I did try to duplicate the env inside next.config.js file too, but the same error

Solved$10 Bounty

2 Replies

Railway
BOT

a month ago


Anonymous
PROOP

a month ago

Closing this, found the solution here: https://docs.railway.com/guides/dockerfiles#using-variables-at-build-time

Include variable names as ARG in the docker file


Status changed to Solved brody 29 days ago


Process.env variable is undefined during `npm run build` (next 14) - Railway Help Station