Environment variables #5328
shiba-codes
started this conversation in
Ideas
Replies: 0 comments
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.local
fileastro build
is 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_TOKEN
After 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?
Beta Was this translation helpful? Give feedback.
All reactions