bug?: `import.meta.env.VAR` does not work
What version of HonoX are you using?
0.1.40
What steps can reproduce the bug?
Create .env.local with the following contents:
DB_PASSWORD="secret"
Create simple console.log in / route like this:
console.log(import.meta.env.DB_PASSWORD)
What is the expected behavior?
secret gets printed.
What do you see instead?
undefined gets printed.
Additional information
VITE_ prefixed environment variables are created to be exposed in client code so prefixing DB_PASSWORD with VITE_ would be a bad idea but in this case I have to. So I guess it’s bug?
https://vite.dev/guide/env-and-mode.html#env-variables
Hi @vladimirleonidovich
I'll investigate it. Are you using @hono/vite-dev-server with Vite?
@yusukebe hello there! I do, of course.
This issue is related to @hono/vite-dev-server. I'll transfer this.
Related to #258
Hi @vladimirleonidovich
VITE_prefixed environment variables are created to be exposed in client code so prefixingDB_PASSWORDwithVITE_would be a bad idea but in this case I have to.
You are right. And it's not a bug. It's hard to use, but it's expected behavior. For this case, you have to add VITE_ prefix.