Environment variables Railway error
Hello, I have a problem with environment variables within Railway.
11 days ago, my Next.js app was working correctly, but recently I deployed again and it failed. So, I added a Dockerfile, and the deploy worked. However, now the environment variables are not working. What am I missing?
The enviroment variables are "NEXT_PUBLIC_BASE_URL"
Attached the DockerFile
Publish in my docker local and works correctly
Solution:Jump to solution
1. the ARG lines are commented out
2. these variables are needed during building of the next app, therefore you need to reference them in the same image layer that is responsible for building...
13 Replies
Project ID:
a2d0a173-be4f-421a-b1b0-ada4f0b76aa2
a2d0a173-be4f-421a-b1b0-ada4f0b76aa2
your dockerfile is missing the reference to
NEXT_PUBLIC_BASE_URL
and whatever other variables you may need, please read this https://docs.railway.app/guides/dockerfiles#using-variables-at-build-timeit didnt work
Add to dockerFile
ARG NEXT_PUBLIC_BASE_URL
RUN echo $NEXT_PUBLIC_BASE_URL
command run echo
if see it value in build Logs Railway
show me the dockerfile you have now please
please enclose that in a code block
please enclose that in a code block
that works too
Solution
1. the ARG lines are commented out
2. these variables are needed during building of the next app, therefore you need to reference them in the same image layer that is responsible for building
If the variable line 36 is present, (NEXT_PUBLIC_BASE_URL)
The commented variables are only for testing
okay that solves 1. please read 2.
Thanks
Its working
awesome
New reply sent from Help Station thread:
what should i do about to fix it here, i have the same problem, the variables are not detected by railway:You're seeing this because this thread has been automatically linked to the Help Station thread.