You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix error loading .env.local into ALL builds, regardless of environment (#4621)
# Description and Motivation
<!--- bulleted, high level items. use keywords (eg "closes#144" or
"fixes#4323") -->
This pull request resolves an issue where Vite's default behavior of
loading .env.local caused local development environment variables to
inadvertently affect other build processes. The solution involves
renaming the local environment file to .env.localhost and systematically
updating all related scripts, code, and documentation. This change
ensures a clear separation of local development configurations from
other environments, leading to more robust and predictable builds.
Highlights
- Environment Configuration Refinement: Renamed frontend/.env.local to
frontend/.env.localhost to prevent unintended loading by Vite in
non-local builds, ensuring environment variable isolation.
- Script and Code Alignment: Updated npm scripts in package.json and
internal code references in DataFetcher.ts and Environment.ts to reflect
the new localhost naming convention.
- Documentation Update: Modified README.md to guide developers on using
the new npm run localhost command and the .env.localhost file.
- Git Ignore Enhancement: Added frontend/.env.local to .gitignore to
prevent accidental commits of the old, problematic file name.
## Has this been tested? How?
need to merge and deploy to full test; success will be demonstrated when
network calls from the PROD website no longer route to
`dev.healthequitytracker.org` as they are currently. This was because
the base API en variable was set in the now deprecated `.env.local`
file, the assumption being that file loaded ONLY in local development.
However, Vite loads that file whenever it's present, and merges with
other loaded files, so this file was being loaded in deploy preview and
dev environments, but ALSO in prod making the data_server URL incorrect
## Screenshots (if appropriate)
ERROR
<img width="1568" height="516" alt="image"
src="https://github.com/user-attachments/assets/46665166-9e1e-4fde-a4ad-5d519ee8dad7"
/>
## Types of changes
(leave all that apply)
- Bug fix
- Refactor / chore
## New frontend preview link is below in the Netlify comment 😎
0 commit comments