Missing environment variables on Cloudflare workers
https://github.com/kylekz/tss-cf-workers
i've taken the
the main branch uses a singular
the
in the server function thats called in the index route loader, the server variable access errors due to variables being invalid, so the worker crashes with a 500. i switched this to lazy load the env object, catch the error and return a fallback. then the client object fails validation and errors.
i've defined both vars in the worker dashboard under the runtime variables and secrets section, not the build section. i've also tried importing
in my actual app, i can't even finish a deploy as i assume the build/deploy process attempts a health check of some sort, but hits the invalid environment variables error and the deploy fails:
at this point i'm completely stumped and almost positive i'm just doing something wrong with cloudflare/wrangler
i've taken the
pnpm create @tanstack/start@latest starter, picked tailwind + eslint + t3env + upgraded all packages to latest. then added one server var and one client varthe main branch uses a singular
env.ts as per the starter, which doesn't work when running pnpm dev as server vars don't get loaded into import.meta.env, let alone attempting to deploy thisthe
split-env branch has separate client and server env objects: client using import.meta.env and server using process.env (which should work due to the wrangler compatibility date)in the server function thats called in the index route loader, the server variable access errors due to variables being invalid, so the worker crashes with a 500. i switched this to lazy load the env object, catch the error and return a fallback. then the client object fails validation and errors.
i've defined both vars in the worker dashboard under the runtime variables and secrets section, not the build section. i've also tried importing
env from cloudflare:workers which results in the same issue.in my actual app, i can't even finish a deploy as i assume the build/deploy process attempts a health check of some sort, but hits the invalid environment variables error and the deploy fails:
at this point i'm completely stumped and almost positive i'm just doing something wrong with cloudflare/wrangler