#Load secret variable from .env without exposing to client

12 messages · Page 1 of 1 (latest)

subtle breach
#

yes, prefixing with VITE_ exposes to the client. for env variables you don't want exposed you have to use process.env with a non-prefixed variable

warped citrus
#

@subtle breach I was following your example with process.env['MONGODB_USER'] but it doesn't seem to work

#

I name my file .env if that helps with my explanation

subtle breach
#

I'm gonna be honest, I don't fully understand environment variables. maybe if you give more of the context of your codebase? and maybe @carmine wave or @signal hollow could help better, they are def more experienced with solid and vite than me

warped citrus
#

But I'm not sure how I can get it to work on my project yet

hybrid tinsel
#

That's old. Create React App clone

#

I should deprecate it. It has been dead for 2 years

warped citrus
#

Could you point to a place that works with .env file?

hybrid tinsel
warm shuttle
#

Ye there are examples mentioned there