I am using Vue 3 with vite as my dev server... I have two .env files configured for my vite setup, .env and .env.development, and I seem unable to use the variables within them...
.env
VITE_API_KEY="1234"
VITE_API_URL="https://www.myapi.com"
.env.development
VITE_API_KEY="5678"
VITE_API_URL="https://www.staging.myapi.com"
Could someone help me understand why when I use my variables like this import.meta.env.VITE_API_URL, I just get this in the console;
Cannot read properties of undefined (reading 'VITE_API_URL'), and if i use process. I get Process is undefined.
I'd also like to add I'm not using dotenv or anything like that...
Good trawl around StackOverflow, but nothing has helped me so far...
I would appreciate any help
install this two package
package.json file add this cmd
using
const ApiBaseUrl = import.meta.env.VITE_BASE_URL
local env run that time run
npm run localdevelopment env run that timenpm run devadd both .env file one more key
VITE_NODE_ENV=