mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 12:54:29 +00:00
fix(studio): inject runtime env overrides for pre-built SPA mode
VITE_STUDIO_* env vars set in the user's shell had no effect when running `hyperframes preview` because the pre-built studio bundle had them baked at Vite build time. The embedded Hono server now collects VITE_STUDIO_* vars from process.env and injects them as a `window.__HF_STUDIO_ENV__` script tag into index.html. The client merges this runtime object on top of the baked `import.meta.env`, so flags like VITE_STUDIO_ENABLE_BLOCKS_PANEL=1 work as expected at runtime.
This commit is contained in:
@@ -30,7 +30,16 @@ export function resolveStudioBooleanEnvFlag(
|
||||
// and downstream `env[name]` reads would crash. Fall back to `{}` so
|
||||
// every flag resolves to its declared default outside Vite. Direct
|
||||
// property access keeps Vite's compile-time transform happy.
|
||||
const env = (import.meta.env ?? {}) as StudioFeatureFlagEnv;
|
||||
//
|
||||
// When the studio is served as a pre-built SPA by the embedded Hono server,
|
||||
// `import.meta.env` values were baked at build time. The server injects
|
||||
// `window.__HF_STUDIO_ENV__` with any `VITE_STUDIO_*` env vars from the
|
||||
// user's shell, so runtime overrides take precedence over baked defaults.
|
||||
const runtimeEnv =
|
||||
typeof window !== "undefined"
|
||||
? ((window as Window & { __HF_STUDIO_ENV__?: StudioFeatureFlagEnv }).__HF_STUDIO_ENV__ ?? {})
|
||||
: {};
|
||||
const env = { ...(import.meta.env ?? {}), ...runtimeEnv } as StudioFeatureFlagEnv;
|
||||
|
||||
export const STUDIO_PREVIEW_MANUAL_EDITING_ENABLED = resolveStudioBooleanEnvFlag(
|
||||
env,
|
||||
|
||||
Reference in New Issue
Block a user