Why would `process.env.EXAMPLE` be
Why would
process.env.EXAMPLE
be undefined in vite.config.ts
only in cloudflare pages? It works locally, if I export EXAMPLE=hello
and build, I can see hello
in vite.config.ts. But in the Cloudflare Pages build, it's undefined
.
Would anyone know whats going on there 🤔️🙏🏼️7 Replies
Ohh,
process.env. doesn't exist in Cloudflare workersI just need to use it directly, like
EXAMPLE
. UnconventionalI don’t see how it’d exist directly either
The build environment is a Ubuntu container, that runs Node
Workers and Functions runtime aren’t Node, they’re a custom runtime, and variables are provided to the fetch handler
Oh, I guess it wouldn't work
Im just trying to get my environment variables in the build process, which for me is node 21. So I'm still not sure why
process.env.EXAMPLE
is undefinedDo you see the default ones, like CF_PAGES_BRANCH?
Nope, that's undefined too. I ran:
Which gives me:
ahh it might be my use of turbo 🥹
I think i've found a bug in turbo... This doesn't work:
I need to put it in
Yea, that's fixed it :), thanks for your replies
Are you using Hono?
If so, see how I add env variables here (on hono discord)
https://discord.com/channels/1011308539819597844/1012485912409690122/1181284862683009094
Nope I use tRPC running on Node (not on cloudflare workers). I only have a cloudflare pages frontend running on cloudflare pages
I'll still take a look, thanks for the link