Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐞] vite incorectly processes import.meta.env in examples #4569

Closed
mhevery opened this issue Jun 22, 2023 · 4 comments
Closed

[🐞] vite incorectly processes import.meta.env in examples #4569

mhevery opened this issue Jun 22, 2023 · 4 comments
Labels
STATUS-2: missing info Incomplete issue/pr template or missing important information TYPE: bug Something isn't working WAITING FOR: user Further information is requested from the issue / pr opener

Comments

@mhevery
Copy link
Contributor

mhevery commented Jun 22, 2023

Which component is affected?

Qwik Runtime

Describe the bug

  1. This line: https://github.com/BuilderIO/qwik/blob/main/packages/docs/src/routes/docs/labs/insights/index.mdx#L34
  2. Generates:
    image
    notice ({}) when it should be import.meta.env

Reproduction

https://qwik.builder.io/docs/labs/insights/

Steps to reproduce

Navigate to: https://qwik.builder.io/docs/labs/insights/
See: image
notice ({}) when it should be import.meta.env

System Info

na

Additional Information

No response

@mhevery mhevery added TYPE: bug Something isn't working STATUS-1: needs triage New issue which needs to be triaged labels Jun 22, 2023
@manucorporat
Copy link
Contributor

it's almost like a vite / mdx issue

@TimKieu
Copy link

TimKieu commented Oct 10, 2023

VITE: I also face this ENV with Vite React and Vite Hono/Express.
Vite cannot process import.meta.env or the older process.env

@gioboa
Copy link
Member

gioboa commented Oct 10, 2023

🤔 that's because you need to call the env variables with the prefix VITE_

Extract from the documentation

To prevent accidentally leaking env variables to the client, only variables prefixed with VITE_ are exposed to your Vite-processed code. e.g. for the following env variables:

VITE_SOME_KEY=123
DB_PASSWORD=foobar
Only VITE_SOME_KEY will be exposed as import.meta.env.VITE_SOME_KEY to your client source code, but DB_PASSWORD will not.

console.log(import.meta.env.VITE_SOME_KEY) // 123
console.log(import.meta.env.DB_PASSWORD) // undefined

I think we can close this issue, @TimKieu is it solved for you?

@shairez shairez added WAITING FOR: user Further information is requested from the issue / pr opener STATUS-2: missing info Incomplete issue/pr template or missing important information and removed STATUS-1: needs triage New issue which needs to be triaged labels May 25, 2024
Copy link
Contributor

github-actions bot commented May 25, 2024

Hello @TimKieu . Please provide the missing information requested above.
Issues marked with STATUS-2: missing info will be automatically closed if they have no activity within 14 days.
Thanks 🙏

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATUS-2: missing info Incomplete issue/pr template or missing important information TYPE: bug Something isn't working WAITING FOR: user Further information is requested from the issue / pr opener
Projects
None yet
Development

No branches or pull requests

5 participants