React.js with Vite process.env is not work

Hey there. I am so new to here. This is first time to me that i use Vite React. When i try to add .env variables an error happened which that:
Uncaught (in promise) ReferenceError: process is not defined

How can i fix it?

Hi. Welcome to the community. Just a note: Glitch is ending hosting on July 8th. While I hope your issue gets fixed, you won’t be able to make any Glitch projects after July 8th.

.env is for setting up environment variables in server side code. if you’re trying to access these in browser code, you’ll indeed get this error about process not being defined. Vite might have some special way to arrange for environment variables to be put into the browser code at build time. but if those variables are meant to be secret, then do think about whether it’s okay for them to be put into public js files.

I am sorry to hear that but thank you for inform me.

Yeah i think i can. There are some api urls and other env things. Thank you, this was really helpful

1 Like