A Build Plugin That Stamps Every HTTP Request with the Frontend Version
Production debugging still depends on asking users to clear their cache or guess which build they have. Stamping every request with the frontend version turns backend logs into a reliable source of truth and eliminates a recurring source of friction between frontend teams and ops.
Frontend version information rarely makes it into backend logs. When a production bug surfaces, the first question is always "which build is the user on?" and the answer is usually a guess. unplugin-version-injector 2.2 closes that gap by injecting a small script that wraps fetch and XMLHttpRequest, automatically attaching X-Client-Version and X-Client-Build-Time headers to every request.
The plugin works across Vite, Webpack, Rspack, Rollup, and Rolldown with a single line of config. Same-origin requests get headers by default; cross-origin APIs require an explicit include list plus backend CORS opt-in. A monorepo setup can read API origins from environment variables so the same shared config works across dev, sandbox, and production.
Beyond request headers, the plugin also stamps a meta tag into the HTML and prints a styled build banner to the console. The 2.2 release adds Rspack and Rolldown support, a dayjs-style date formatter with zero dependencies, full TypeScript types, and 26 unit tests covering the injection logic.
Frontend version observability is a solved problem at the infrastructure level for backend services, but frontend builds remain opaque once deployed. This plugin treats the browser the same way a microservice treats its own health endpoint.
The design choice to default to same-origin-only and require an explicit cross-origin whitelist is the right security posture. It prevents the plugin from silently breaking third-party integrations while still making the common case effortless.
Monorepo support via environment variables is the detail that separates a demo from a tool that survives real multi-environment pipelines. Hardcoding domains in build config is a maintenance trap that most teams hit within weeks.