[Vuejs]-Error when I use process.env with Vue and Vite

0πŸ‘

βœ…

Only variables prefixed with VITE_ are exposed. Source

Vite uses import.meta.env

0πŸ‘

I had a similar problem using React and Vite.

I swapped out

apiKey: process.env.PUBLIC_API_KEY,

for

apiKey: import.meta.env.VITE_PUBLIC_API_KEY

etc.

Then, I needed to move sure my .env.local file was in my src folder, and rename varaibles in .env.local of course

Leave a comment