I'm creating a full stack app with vite/react and node.js I have to use an API key in my backend to interact with GPT but ofcourse, I want to use that in my .env file.
However, whatever I try, my backend reads the environment variable as undefined..
I've went on the internet to find solutions but nothing works so maybe there is like something new going on..
My .env file (Which is in the same path as my package.json)
REACT_APP_API_KEY ='HERE IS MY SECRET KEY'
// or //
VITE_API_KEY ='HERE IS MY SECRET KEY'
and in my server.js (Is in the same path as the .env file)
console.log(process.env.REACT_APP_API_KEY)
// or //
console.log(import.meta.env.VITE_API_KEY)
These both options return undefined..
I also want to mention that I do have the cross-env package installed. So I've absolutely no clue what Ï'm doing wrong..