Prod Environment Variables Please
I'm maybe just doing something silly but when i do an npm run dev i can access env variables but not after an npm run build, i made a simple reproduction:
-
npm create solid => basic => ts
app.config.ts:
middleware.ts:
.env: test=aloha
- npm run dev refresh app, see log of env variable
- npm run build and then npm run start, refresh app, env variable log is undefined š
3 Replies
Several possibilities:
Here's an easy one.
1. install dotenv-cli
pnpm add -D dotenv-cli
2. in package.json change the start command
"start": "dotenv vinxi start",
⬠for secret envs. If it is okay to expose your envs to the client prefix them with VITE_ and access the, with import.meta.env.testSuuuper helpful info both of y'all! Totally fixed it! I appreciate you both!