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
{{ message }}
Repository navigation
Build-machine env vars written into the worker bundle #618
A bare reference to import.meta.env in server code makes Vite write the whole object into the production worker bundle (dist/_worker.js/index.js) as Object.assign(__vite_import_meta_env__, { ... }). That object includes every build-machine environment variable whose name appears anywhere in the same file. The typeof import.meta.env !== "undefined" guard is such a bare reference.
In a local bunx astro build on staging plus PR #617, these still leak:
File
Function
Keys written into the bundle
src/lib/docs-base.ts
resolveDocsBase
TERM, PATH, _ (the full build-machine PATH)
src/lib/api-base.ts
apiBase
_
src/lib/data-base.ts
resolveDataBase
_
src/lib/zarr-base.ts
zarrBase
_
Astro's own action serializers (not our code)
serializeActionResult, deserializeActionResult
_
PR #617 fixed the same leak in src/middleware.ts (which it had introduced), src/lib/osa-widget.ts and src/lib/osa-overview.ts by reading each key by name.
To check: build, then search the worker bundle for Object.assign(__vite_import_meta_env__.
First confirm that nothing imports these modules outside Vite, where import.meta.env is undefined (the guard's original reason).
Add a post-build check that fails when Object.assign(__vite_import_meta_env__ in the worker bundle contains a non-PUBLIC_ key, for example inside scripts/check-quality-views-size.mjs's build step or a new script.
Agentic AI tools were used. Workflows follow the Research Skills (doi:10.5281/zenodo.20696515). The author assumes full responsibility for this content and associated changes.
Activity