Generate dynamic .env during build time. #73069
Unanswered
ArthurWosniaki
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Hello guys!
I have a NextJS application that uses Doppler to store the environment variables. I noticed that, while building the app, SSR pages are using Doppler values in process.env, but CSR pages uses the
.env
file values, which is making SSR and CSR pages display different values for the same process.env variable.I want to make all pages use Doppler values, so at first I transformed the CSR pages into SSR, but then i was thinking instead if it's possible to generate a .env dynamically with Doppler values before starting the build process. I'm assuming that'd need to be done at the start of SSR, before rendering the CSR pages: after running
yarn build
, it'd extract the process.env variables (at this point, using the Doppler values), save them into a.env
file in the root of project, and then the SSR pages will fetch values from Doppler and CSR from .env (that is now written with Doppler values).Is it possible to do it?
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions