Stop Rebuilding Front End Apps for Environment Variables (REP RFC)
3 comments
> Every environment requires rebuilding the same application just to change configuration like API URLs, feature flags, or auth endpoints.
This is not normal. I have never worked anywhere, or on any project, where this was the case. (1) is already how we do things without the other points, which are not needed.
This is not normal. I have never worked anywhere, or on any project, where this was the case. (1) is already how we do things without the other points, which are not needed.
This is in context of Containerised Frontends. curious to know how you've handled this as this a huge problem in containerised frontend builds.
All of my services are containerized including their builds. It's not a "huge" problem, it's simple to deal with, including frontend builds. I suggest reading the documentation or asking an Ai how people in industry deal with this. Most of the Show HN posts like this can be better solved by asking an Ai how we already do things, as opposed to having it come up with an over engineered solution.
Backend systems solved this problem long ago with runtime configuration. You build once and configure the application when it starts.
Static webapps never got a clean equivalent.
Most solutions today are ad-hoc: - env.sh scripts that rewrite bundles - CI pipelines rebuilding per environment - templating HTML files - framework-specific hacks
These approaches are fragile and tied to specific build tools.
I’ve been working on a small protocol called REP (Runtime Environment Protocol) that tries to solve this in a portable way.
The idea is simple: 1. Infrastructure provides configuration as environment variables. 2. A gateway injects them into the HTML response as a JSON payload. 3. The frontend reads them at runtime through a small SDK. 4. The payload is integrity-verified to prevent tampering.
example injected payload: <script id="__rep__" type="application/json"> { "public": { "API_URL": "https://api.example.com" }, "_meta": { "integrity": "sha256-..." } } </script>
The frontend can then read configuration at runtime instead of at build time.
This enables: • build once, deploy anywhere • environment configuration via infrastructure • compatibility with static hosting and CDNs • no rebuilds when configuration changes
The spec focuses on three things: • a standard payload format • secure integrity verification • predictable injection semantics
I’m sharing it mostly to get feedback from people who deal with deploying frontend apps at scale.
Spec: https://github.com/RuachTech/rep/blob/main/spec/REP-RFC-0001.md
URL: https://rep-protocol.dev
Curious if others have run into the same pain or solved this differently.