Skip to content

fix(studio): inject runtime env overrides in embedded mode#1011

Closed
miguel-heygen wants to merge 1 commit into
mainfrom
fix/studio-runtime-env-flags
Closed

fix(studio): inject runtime env overrides in embedded mode#1011
miguel-heygen wants to merge 1 commit into
mainfrom
fix/studio-runtime-env-flags

Conversation

@miguel-heygen
Copy link
Copy Markdown
Collaborator

Summary

  • VITE_STUDIO_* env vars (e.g. VITE_STUDIO_ENABLE_BLOCKS_PANEL=1) set in the user's shell were silently ignored when running hyperframes preview in embedded mode (pre-built SPA). Vite bakes import.meta.env at build time, so runtime env vars never reached the client.
  • The embedded Hono server now collects VITE_STUDIO_* vars from process.env and injects them as window.__HF_STUDIO_ENV__ into the served HTML. The client merges these runtime overrides on top of the baked import.meta.env, so runtime values take precedence.

Test plan

  • VITE_STUDIO_ENABLE_BLOCKS_PANEL=1 npx hyperframes preview shows the Blocks tab in embedded mode
  • Without the env var, Blocks tab remains hidden (default behavior unchanged)
  • Dev mode (bun run dev) continues to work as before (Vite handles env vars natively)

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.
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

Successfully merging this pull request may close these issues.

1 participant