Process.env variable is undefined during
npm run build(next 14)
Anonymous
PROOP
10 months 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
2 Replies
Railway
BOT
10 months ago
Hey there! We've found the following might help you get unblocked faster:
- 🧵 Docker Build Not Receiving Environment Variables as ARGs Despite railway.toml Configuration
- 🧵 Title: Railway + Nixpacks: Next.js build fails due to unresolved @ alias (monorepo setup)
- 🧵 Service Environment Variables Not Accessible in Runtime (Next.js, Nixpacks)
If you find the answer from one of these, please let us know by solving the thread!
Anonymous
PROOP
10 months 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 • 10 months ago