My Nextjs project works properly but env. variables comes undefined when we deploy the project into Docker cont. (We defined env. variables in Docker.)
I read the Nextjs documentation and noticed that:
Note: After being built, your app will no longer respond to changes to these environment variables. For instance, if you use a Heroku pipeline to promote slugs built in one environment to another environment, or if you build and deploy a single Docker image to multiple environments, all NEXT_PUBLIC_ variables will be frozen with the value evaluated at build time, so these values need to be set appropriately when the project is built. If you need access to runtime environment values, you'll have to setup your own API to provide them to the client (either on demand or during initialization).
I wanna try to access my env. variables at runtime but I dont know how can I do that? Project version: Nextjs 14 App Router
I have a .env.local file and there is just a one env. variables that starts with NEXT_PUBLIC pretag.
I make lots of research but I didnt find a proper way to fix it. I just wanna know how can I use my env. variables at runtime in a Nextjs 14 App Router project?