Node Environment Variable Is Undefined For Express Server but Defined In Vite React Front End
I have a .env file in the root directory of a react vite project. Next to it I have two folders, one for an index.js that is an express server and one that is a src folder for my front end components. In my App.jsx component, I can easily access an environment variable in that .env file with
import.meta.env.VITE_MY_API_KEY
. I don’t even need to import anything at the top of the component, it just works.