You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I stumbled upon a confusing behaviour yesterday which seems to be undocumented.
Imagine a scenario:
You have some secrets in gitlab that are exported as environment variables in CI
Your build script takes them and puts them into the .env.production.local file
Then, when all necessary variables are in place, astro 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?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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