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

Don't leak .env file into frontend bundle #39

Open
naftis opened this issue Oct 18, 2021 · 1 comment
Open

Don't leak .env file into frontend bundle #39

naftis opened this issue Oct 18, 2021 · 1 comment

Comments

@naftis
Copy link
Collaborator

naftis commented Oct 18, 2021

  1. Import all the env's frontend needs in vite.config.ts define.
  2. Don't import them from shared, but directly refer to them.
  3. Disallow importing @shared/config, and add a ESLint rule to tell the user why not.

..or..


  1. Start using VITE_ -prefixed env variables in shared/config.ts
  2. Import them directly in the frontend

note, both solutions need to have dotenv() configured in vite.config.ts, to load .env file on build.

@eioo eioo pinned this issue Oct 31, 2021
@eioo
Copy link
Collaborator

eioo commented Nov 1, 2021

3rd option, same as 2nd one but change the VITE_ prefix to something more fitting: https://vitejs.dev/config/#envprefix

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

No branches or pull requests

2 participants