Env files are hard
I tried
process.env.VITE_OPENROUTER_API_KEY
import.meta.env.VITE_OPENROUTER_API_KEY
Bun.env.VITE_OPENROUTER_API_KEY
all of them are null19 Replies
process.env is all you need
there are a couple possible issues
what's the name of your env file
just
.env
i assume?yes
and how are you starting the server to test, via vite right?
yeah
bun start
"dev": "bun run build:fake-api && AUTOLOAD_PACKAGES=true vite",
at the top of
vite.config.ts
, log the process.env
so vite.config.ts
in this case is basically the server entrypoint
my guess is what's happening is vite doesn't start with bun
so the issue is probably we need to do bunx --bun vite ...
it's consoling somthing but not my .env

that's probably your env with node
node -e "console.log(process.env)"
i think the --bun
flag will probably workyup it's node env
ok let me check
like this
"dev": "bun run build:fake-api && AUTOLOAD_PACKAGES=true --bun vite",
you need
bunx
in thereI did it crashed
hmm
ok just add dotenv to the vite config file and that's fine
can't make vite run on bun
this is with bunx

yea i have no idea
@Seve what was the issue that caused this on cli

it's just fixed by adding dotenv to vite config ?
yes because the vite config isn't loaded when you import @tscircuit/fake-snippets
the issue was that dotenv was loaded in an endpoint
ok got it , ty
ofc