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
Source:stackexchange.com