i use react with vite and i want to use an env variable in my project. but i got undefined everytime i call the env variable. i have follow the documentation of vite and try a many solutions in internet but it still throw undefined error.
this is my env in .env file
VITE_API_HOST = localhost:9000/api/v1/
and this is when i call the env
const response = await axios.post(`${import.meta.env.VITE_API_HOST}/auth/signin`, {
email: form.email,
password: form.password,
});
i expect to throw the value in my env variable but it always throw undefined.
Farhan Muhammad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.