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

Using ENV variables? #149

Open
osseonews opened this issue Nov 13, 2024 · 1 comment
Open

Using ENV variables? #149

osseonews opened this issue Nov 13, 2024 · 1 comment

Comments

@osseonews
Copy link
Contributor

We noticed that each app has a .env file. How can use custom environment variables defined here in the actual application? We tried to use the standard Vite, import.meta.env.KEY, but that doesn't seem to work. Our use case is that we want to integrate with some third-party apps, and we need to pass an Auth header with a secret to their API, but we don't want to hard code that into the application. So want to use ENV here. Thanks.

@marcomontalbano
Copy link
Member

Hi @osseonews, we changed the prefix from VITE_ to PUBLIC_ to better identify that the env variable will be publicly available to anyone in the bundle.


Last but not least, if you're running the application in your local env with pnpm dev, it runs the package index that works as an orchestrator for all the application. This means that in your local environment you'll need to set the env variables inside the index's .env file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants