next build failed due to serverRuntimeConfig env vars missing #11593
-
Hello guys and thanks a lot for the good effort put on NextJS! : ) I tried to find answers for the following without much success. We are working on a Dockerized NextJS application that is thought to be built once and deployed to several environments for which we will have different configuration. This configuration is to be set in the Docker container when deployed as environment variables. In order to achieve this, we are using
The problem we have is that these variables are not set on build time ( when we run Making a build per environment is not an option: as referred before, we want to build it once (with Is there any way to solve this so that the application builds without environment vars and we pass them afterwards on runtime ( deployment )? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
In case it could be useful for someone else, we finally found the issue. We were importing code in a helper that was being used in the isomorphic side and was relaying on serverRuntimeConfig variables, being then required on build time in order to create the bundle. Removing the import from the helper fixed the issue. |
Beta Was this translation helpful? Give feedback.
-
This confused me for a bit too. Will share my solution from another thread in case it helps anyone else with env vars in a docker environment #13427 (comment) |
Beta Was this translation helpful? Give feedback.
In case it could be useful for someone else, we finally found the issue.
We were importing code in a helper that was being used in the isomorphic side and was relaying on serverRuntimeConfig variables, being then required on build time in order to create the bundle.
Removing the import from the helper fixed the issue.