fix(frontend): CSR builds were missing env vars due to import.meta.env not being used - #657
Merged
daveearley merged 3 commits intoJul 23, 2025
Conversation
…on type and update usages - Defined `ConfigKeys` as a union type for better type safety and clarity. - Updated `clientBuildEnv` to include all keys from `ConfigKeys`. - Enhanced `getConfig` to utilize `clientBuildEnv` for client-side environment variable access.
daveearley
requested changes
Jun 29, 2025
daveearley
left a comment
Contributor
There was a problem hiding this comment.
Thank you, @carlosalaniz!
I can test this later today
Co-authored-by: Dave Earley <dave.m.earley@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refactor(frontend): Replace string-based
ConfigKeyswith a strict union type and update usagesfix(frontend): Ensure Vite CSR builds correctly receive env variables via
import.meta.envDefined
ConfigKeysas a strict union type (no more string fallback).Added
clientBuildEnvwith all keys fromConfigKeys, populated viaimport.meta.env.Updated
getConfig()to resolve environment variables in the following order:process.envduring SSRwindow.hieventswhen injectedclientBuildEnvduring CSRPrior to this change, the app relied on
window.hieventsto access environment variables at runtime. That worked fine for SSR deployments (which most of ours are), since the server injectswindow.hieventsinto the rendered HTML.However, in CSR builds, environment variables like
import.meta.env.VITE_*are injected at build time and are not preserved in the runtime global scope (i.e., not available onwindow). This caused CSR builds to silently break — wrong base URLs, missing logos, broken colors, and failing third-party integrations.This update ensures that both SSR and CSR builds correctly load the expected environment config, restoring reliability and consistency across deployment types.