Can't access environment variables in Vite Vue deploy

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?

Hi @dadandroid :wave:t6: ,

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?

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?