Next js + Docker environment variables #50652
Replies: 3 comments 2 replies
-
To add to the above, I've deployed the app to Vercel and the issue is solved. So this is 100% something to do with Docker. Any help would be incredible. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I've dug deeper and will open a new ticket with more useful information. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi, any news? Have you managed to solve the issue? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey all,
I'm running Next v13.4.1 in a docker container.
I'm having an issue with environment variables in docker.
Running my app locally with
.env
&.env.local
everything works.My docker setup uses an
env_file
& docker compose.I'm finding that at build time the
env_file
variables take priority over the.env
file.How ever, run time events like API calls triggered by the client (app/api/myendpoint/route.ts) seem to be using the value in
.env
.Is there an additional setting i need to change so the
env_file
variables are always read?Another example of this is I have an API endpoint that returns an env variable.
I'm calling this in the route layout and putting it in a context provider. Further down the DOM I'm console logging the value in a client component.
On first load (SSR) the value is correct (from the
env_file
), if i navigate to a new page client side the value is that from the.env
file.n.b. I'm not trying to do anything with NEXT_PUBLIC variables at this stage.
Thanks for any help....i've spent a good few hours looking into this.
Beta Was this translation helpful? Give feedback.
All reactions