#Load secret variable from .env without exposing to client
12 messages · Page 1 of 1 (latest)
this is an example from my project https://github.com/CubeArtisan/cubeartisan/blob/solid/.env_EXAMPLE https://github.com/CubeArtisan/cubeartisan/blob/solid/src/backend/mongoConnection.ts
@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
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
I saw @hybrid tinsel shared this https://github.com/solidjs/solid-scripts/blob/master/config/env.js#L64
But I'm not sure how I can get it to work on my project yet
That's old. Create React App clone
I should deprecate it. It has been dead for 2 years
Could you point to a place that works with .env file?
I don't have an example off hand. It was a community PR from @warm shuttle I believe they use it in create-jd-app https://github.com/solidjs/solid-start/pull/585
.env:
VITE_TEST=1
SERVER_TEST=2
code on client:
console.log("client", import.meta.env.VITE_TEST); // equals 1 - as expected
credits to https://github.com/nuxt/nuxt.js/blob/dev/packages/...
Ye there are examples mentioned there