Improve .env.* usage #30893
Replies: 2 comments
-
there was also a confusion between .dev and .prod: #19388 Gatsby automatically loading dotenv in an undocumented way i think the arguments there can also goes into consideration ... |
Beta Was this translation helpful? Give feedback.
-
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
Beta Was this translation helpful? Give feedback.
-
Summary
Our current setup with
.env.development
and.env.production
has some limitations.GATSBY_
to end up in the client bundle while the.env
files do not have this rule..env
files are used for both server and client development..env
files for server development requires the users to load them in user code.Basic example
From a conversation with @pieh here (sorry its a slack conversation), we think it would be good to make the following changes.
.env.(dev|prod)
files.env.node.(dev|prod)
that would hold node only variables that would get loaded for node runtime.env.browser.(dev|prod)
that would hold only variables that should be exposed to the browser. In addition this file would require all variables be prefixed byGATSBY_
to remain consistent.Motivation
The motivation is to allow our APIs to remain clear and prevent security holes.
Beta Was this translation helpful? Give feedback.
All reactions