#Environment variable on the front end.

1 messages · Page 1 of 1 (latest)

cyan dome
#

Has anyone got an idea about how to show env vars in a bun fullstack app on the front end?

E.g I want to print my NODE_ENV or BUN_PUBLIC_NODE_ENV

I have a bunfig.toml with

I have tried to use

process.env*
Bun.env
import.meta.env

But i cant seem to expose this on the front end

An help would be appreicated

jolly gyro
#

strange that it's not working

#

is env = inside [serve.static] in bunfig.toml?

unkempt vessel
jolly gyro
#

@unkempt vessel it works similar to find and replace (but with the ast). is the environment variable statically analyzable? like process.env.FOO and not process.env[myVariable]

unkempt vessel
#

Yeah, they are statically analyzable, like when i try to run this code:

const HOST = process.env.BUN_PUBLIC_HOST_URL;
const PORT = import.meta.env.BUN_PUBLIC_PORT;

I got process is not defined and hmr.importMeta.env is undefined

unkempt vessel
#

I filed an issue on Github