having trouble with next.js environment variables with docker image and coolify
Unanswered
Chris Westbrook posted this in #help-forum
I am trying to host a next.js app on my server that is managed by coolify. All of my NEXTPUBLIC environment variables are not being exposed, even though I have checked the build variables checkbox in coolify. Has anyone else gotten this to work?
1 Reply
English Lop
Hi, i follow this comment to achieve NEXT PUBLIC environment variables
https://github.com/vercel/next.js/discussions/14030#discussioncomment-24692
Using build args:
NEXT_PUBLIC_ORIGIN: $NEXT_PUBLIC_ORIGIN # (from env file)
NEXT_PUBLIC_ORIGIN: github.com/vercel/... # (hardcoded)
Then in Dockerfile:
ARG NEXT_PUBLIC_ORIGIN
ENV NEXT_PUBLIC_ORIGIN=${NEXT_PUBLIC_ORIGIN}
https://github.com/vercel/next.js/discussions/14030#discussioncomment-24692
Using build args:
NEXT_PUBLIC_ORIGIN: $NEXT_PUBLIC_ORIGIN # (from env file)
NEXT_PUBLIC_ORIGIN: github.com/vercel/... # (hardcoded)
Then in Dockerfile:
ARG NEXT_PUBLIC_ORIGIN
ENV NEXT_PUBLIC_ORIGIN=${NEXT_PUBLIC_ORIGIN}