Preview Banner
Diverge can automatically inject a visual banner into your web applications to clearly indicate when you are viewing a preview environment.
How It Works
Section titled “How It Works”The Diverge proxy intercepts HTML responses and injects a lightweight, non-intrusive preview banner just before the closing </body> tag. The banner provides immediate visual feedback that traffic is being routed to an ephemeral preview environment rather than production.
Configuration in .diverge.yaml
Section titled “Configuration in .diverge.yaml”Starting in Diverge v0.10.0, you can configure the preview banner globally in your repository’s .diverge.yaml:
version: "1"defaults: routing: banner: enabled: true # Set to false to hide the banner text: "PR Preview" # Custom banner label position: bottom # "top" or "bottom" color: "#6366F1" # Hex color code for banner accentEnvironment & Label Overrides
Section titled “Environment & Label Overrides”Banner settings support hierarchical inheritance. You can enable the banner by default for feature branches while hiding or restyling it for specific environments:
version: "1"defaults: routing: banner: enabled: true position: bottom color: "#3B82F6"
environments: # Hide banner for staging previews staging: routing: banner: enabled: false
# High-priority hotfix previews with distinct warning color hotfix: routing: banner: enabled: true text: "⚠️ HOTFIX PREVIEW" position: top color: "#EF4444"CRD Configuration
Section titled “CRD Configuration”You can also specify or override banner settings directly on the Environment custom resource:
apiVersion: divergedev.com/v1alpha1kind: Environmentmetadata: name: pr-42spec: routing: banner: enabled: true text: "Review Env #42" position: bottom color: "#10B981"Disabling the Banner
Section titled “Disabling the Banner”If your end-to-end tests or visual regression pipelines require pixel-perfect screenshots without injected markup, disable the banner globally in .diverge.yaml:
version: "1"defaults: routing: banner: enabled: falseIn-Browser Floating DevToolbar (<diverge-toolbar>)
Section titled “In-Browser Floating DevToolbar (<diverge-toolbar>)”When traffic is routed through diverge-proxy, Diverge injects a Shadow DOM-isolated floating toolbar (<script src="/-/toolbar.js" defer></script>) before </body> on eligible text/html responses (excluding responses where toolbar injection is disabled, the body is encoded or exceeds the inspection limit, or no closing </body> tag is present):
- Active Environment Pill: Displays the currently active preview environment (
diverge_envcookie, subdomain, or header) orbaseline. - Environment Switcher Dropdown: Populated dynamically from
GET /-/api/context, allowing 1-click switching between preview environments visible in the proxy’s configured Kubernetes namespace. - Copy Magic Link (
?_diverge_env=<env>): Copies a shareable URL that sets thediverge_envcookie automatically for PMs, designers, or QA reviewers. - Reset to Baseline: Navigates to
?_diverge_env=clear(or?_diverge_env=reset) to expire the preview cookie and return to baseline traffic. - Collapsible Pill (
localStoragePersistence): Includes an interactive collapse/expand toggle (#diverge-collapse-btn,aria-expanded) that minimizes the toolbar down to a compact⚡ <env>pill and persists state across page reloads vialocalStorage(diverge_toolbar_collapsed).
To skip <diverge-toolbar> injection on a specific request (for example during automated screenshot capture), pass the X-Diverge-Toolbar: off request header.
