-
Notifications
You must be signed in to change notification settings - Fork 918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow dotenv files from different environments for SSR and SSG in Next.js #7323
base: master
Are you sure you want to change the base?
Conversation
…the build process
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some test coverage?
…osalvador/dotenv-files
…base-tools into chalosalvador/dotenv-files
const projectEnvVars = parseStrict((await readFile(projectEnvPath)).toString()); | ||
|
||
// Merge the parsed variables with the existing environment variables | ||
Object.assign(env, projectEnvVars); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dotenv does not override environment variables by default if i recall, so this logic will likely need inverting { ...projectEnvVars, ...process.env }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See small comment on overrides, add tests, and changelog—otherwise LGTM
Description
This PR is intended to fix the issue #7207 by checking if the .env. file exists and make it available for the build process.
Scenarios Tested
.env.<PROJECT-ID>
file in the root of the Next.js project.env.<PROJECT-ID>
.env.<PROJECT-ID>
.env.<PROJECT-ID>
is available in a server side rendered page..env.<PROJECT-ID>
is available in a static generated page.Sample Commands