-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Wrong envPrefix in Astro Integration #689
Comments
Only variables starting with VITE_ will be exposed by vite https://vitejs.dev/guide/env-and-mode.html#env-variables-and-modes 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. |
That prefix can be customized with the envPrefix option. |
Yeah, you can change it, but only those env vars starting with the prefix will be available via |
You can configure empty prefix (vite will thow an error), you will need to use define |
Read the |
Yes, that's what I want. I want to make VitePWA to use the same prefix as Astro: |
Oops. Sorry, I thought this was a monorepo. I moved this issue to the correct repository. |
Hi, thank you very much for this library.
I'm using the Astro Integration and I discovered that all my PUBLIC_* variables are been ignored after build in my custom service worker.
I tested with the following variables:
I saw that the VITE_SAMPLE variable is included but not PUBLIC_SAMPLE.
The default value of envPrefix in Vite is VITE_ but in Astro the prefix is PUBLIC_ for client scripts.
Is there a way to change that?
The text was updated successfully, but these errors were encountered: