Environment variables #5328
Closed
shiba-codes
started this conversation in
Ideas
Replies: 1 comment
|
We're closing stale and outdated discussion to keep only the discussions still relevant to the current project version and/or the current docs state. Sorry no one could answer your question before but, Astro has now a new way to handle environment variables and this behavior is now documented in https://docs.astro.build/en/guides/environment-variables/#variable-types. So, I'm going to close this as resolved. If you think this is a mistake and that this discussion should remain open, please feel free to ping me, I'll take a second look at it. Thank your for your contribution! |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi folks! Thanks for doing an awesome job 💟
I stumbled upon a confusing behaviour yesterday which seems to be undocumented.
Imagine a scenario:
.env.production.localfileastro buildis called.What happened when built locally
Variable values were interpolated into the built code like this:
const API_TOKEN = "secret"What happened in CI
const API_TOKEN = process.env.API_TOKENAfter excessive googling and consulting the docs of both Astro and Vite we could not find anything that would explain this behaviour. Eventually we figured it out: when the variable is set but is also present in some .env file, it won't be set again. Instead, it will be expected to be present and be provided in runtime. Everything worked as expected after unsetting those variables.
I think this behaviour should be documented! What do you think?
All reactions