TanStackT
TanStack10mo ago
2 replies
verbal-lime

Server and client environment variables are being loaded from different .env files.

Hello, I'm working on tanstack/start app in monorepo. I also configured /src/ directory to better organize the files. The issue is that server environment variables (from process.env) are being loaded from web/src/.env, while the client variables (from import.meta.env) are being loaded from web/.env.

I found that I can set vite.envDir in
app.config.ts
. I can technically use this to solve my issue, but the
.env
file would have to live in /web/src. This is not ideal. Instead I'd like the
.env
file to live in /web. But I couldn't find any way to set path for server envs.

Is there way to set which file the server envs are loaded from? Or possibly, is there any other solution to my issue?
Was this page helpful?