# How REP Works — Gateway Architecture and HTML Injection > How the REP gateway injects environment variables into HTML at runtime. Proxy and embedded modes, startup sequence, script tag injection, and SDK initialization. Source: https://rep-protocol.dev/concepts/how-it-works/ ## Architecture REP introduces a lightweight gateway process between the browser and your static file server. The gateway reads `REP_*` environment variables at startup, classifies them, and injects a ` ``` **Injection rules:** 1. Insert before `` (preferred) 2. If no ``, insert after `
` 3. If neither exists, prepend to the response body > **Caution** > > `type="application/json"` is critical — it prevents the browser from executing the tag. This is inert data, not executable JavaScript. Never change this to `text/javascript`. ## SDK initialization The SDK reads the injected payload **synchronously** on import: 1. Locate `