I am trying to deploy a Vite Vue app. I’ve set some env variables through netlify UI namely VITE_URL="url"
and VITE_RED="redirect"
When I run netlify dev
I can acesss them within my app with import.meta.env.VITE_URL
and import.meta.env.VITE_RED
. However, when I run netlify deploy
I get undefined
when I call them the same way.
Any ideas what am I doing wrong?
SamO
March 24, 2023, 1:34pm
2
Hi @dadandroid ,
Welcome to the forums, i’m glad you found us. Are you specifying your environment variable in the Netlify configuration.
Hi @SamO thanks for your answer.
I’ve set some env variables through netlify UI namely VITE_URL="url"
and VITE_RED="redirect"
Yes, I’m specifying the variables through the netlify website:
Still, not working though. I would appreciate any help to understand why I cannot access this variables.
@SamO any thoughts about this? Or perhaps you could tag someone who might know what is going on?
fool
March 27, 2023, 11:34pm
5
Can you explain anything more about this statement? I can’t see how we’d do this at runtime:
when I run netlify deploy
I get undefined
when I call them the same way.
How exactly are you calling them, from what code, that is run, at what time?
I often suggest that people prepend env &&
to their build command, to show that we do find the variables during build - have you tried that yet?