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
If this issue only occurs in one browser, which browser is a problem?
Not browser related.
Describe the Bug
Just built my first site with Astro (migration from Gatsby).
It was a real pleasure to work with it, easy to learn, works great, big thanks to the whole team for this awesome work!
If found some strange behavior with env vars defined in astro.config.mjs env schema.
With static pages and some access: "secret" env vars, everything behaves correctly on dev, preview and production modes.
With SSR pages and some access: "secret" env vars, everything behaves correctly on dev mode, however on preview and production modes, runtime generation fails, claiming for those secret env vars while none of my SSR pages or components use them in the code.
What's the expected result?
SSR pages shouldn't claim for env vars they don't use, even if they are in schema.
SSR pages shouldn't work ind dev mode and fail in preview mode when using same env vars (it should not fail at all, or at least fail in both modes).
I may be misunderstanding what you're expecting, but in the example you share, the problem is that the static page is importing the secret var, which is why it complains about it being missing. If you remove that then it builds fine without it.
If you mark an env var as secret and only use it in SSR, then it won't complain about it being unset at build because it's expecting it to be set at runtime. If you mark it as public then it will complain, because it wants to inline it.
If you want it to not complain about missing env vars then you need to set them as optional. You can then check it yourself.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
Not browser related.
Describe the Bug
Just built my first site with Astro (migration from Gatsby).
It was a real pleasure to work with it, easy to learn, works great, big thanks to the whole team for this awesome work!
If found some strange behavior with env vars defined in
astro.config.mjs
env schema.With static pages and some
access: "secret"
env vars, everything behaves correctly on dev, preview and production modes.With SSR pages and some
access: "secret"
env vars, everything behaves correctly on dev mode, however on preview and production modes, runtime generation fails, claiming for thosesecret
env vars while none of my SSR pages or components use them in the code.What's the expected result?
Link to Minimal Reproducible Example
Everything is well described in my example's README.md:
https://github.com/Fenykepy/astro-env-vars-example/
Participation
The text was updated successfully, but these errors were encountered: