Browser Live-Reload (DevReload)
Development-only middleware that makes open browser tabs reload automatically while running under regius dev.
Features
- Opt-in via
DEV_RELOAD_ENABLED—regius devsets it automatically for the dev process, so no app code or config is needed - When enabled it mounts three endpoints under
DEV_RELOAD_PATH(default/__dev):GET /__dev/reload.js— the same-origin reload client (no inline scripts, CSP-safe)GET /__dev/stream— an SSE stream announcing a per-process boot ID (tabs reconnect after a restart and reload when the ID changes; aretry: 500hint keeps the reconnect fast)POST /__dev/notify— loopback-only trigger that pushes a reload event to connected tabs (used byregius devafter CSS-only Tailwind rebuilds; requests with proxy headers are rejected so a spoofedX-Forwarded-Forcannot bypass the check)
<script src="/__dev/reload.js" defer></script>is injected before the closing</body>of HTML responses. Non-HTML responses pass through untouched, HTML fragments without a</body>tag are left alone,Content-Lengthis dropped when injecting, and a mid-streamFlushgives up injection so streaming handlers keep working- Responses without a
Content-Typeare sniffed withhttp.DetectContentType— the same rule net/http applies — so pages render identically with and without the middleware - When disabled (the default) the middleware is a pure passthrough and nothing is mounted: production behavior is byte-identical
warning
Never set DEV_RELOAD_ENABLED=true in production. The notify endpoint can force connected tabs to reload, and the injected script adds a development-only SSE connection to every page.
Environment Variables
DEV_RELOAD_ENABLED=false # set automatically by `regius dev`
DEV_RELOAD_PATH=/__dev # base path for the reload endpoints