Live
Secure In‑Browser Dev Server Previews with Cloudflare Agents Internal HostnamesRTX Spark laptops add unified GPU‑CPU superchip and on‑device AI models – what engineers need to knowScaling Identity for Agentic Workloads: Lessons from OpenAI’s 1.2 B‑User DeploymentGitHub Copilot Fusion introduces dynamic model routing for enterprise AI workloadsAI Governance Gets a Runtime Layer: Docker’s Navigator Partner Program for EngineersCopilot security extension embeds code‑scanning alerts directly in the editorLeverage GKE‑Enriched VPC Flow Logs for Faster Network TroubleshootingScaling GKE Dataplane V2 for High‑Density AI SandboxesSecure In‑Browser Dev Server Previews with Cloudflare Agents Internal HostnamesRTX Spark laptops add unified GPU‑CPU superchip and on‑device AI models – what engineers need to knowScaling Identity for Agentic Workloads: Lessons from OpenAI’s 1.2 B‑User DeploymentGitHub Copilot Fusion introduces dynamic model routing for enterprise AI workloadsAI Governance Gets a Runtime Layer: Docker’s Navigator Partner Program for EngineersCopilot security extension embeds code‑scanning alerts directly in the editorLeverage GKE‑Enriched VPC Flow Logs for Faster Network TroubleshootingScaling GKE Dataplane V2 for High‑Density AI Sandboxes
Cloudflare

Secure In‑Browser Dev Server Previews with Cloudflare Agents Internal Hostnames

AI SummaryPowered by AI

The Agents SDK now lets the persistent browser resolve internal hostnames, enabling dev‑server previews without exposing public URLs. This reduces surface area and simplifies testing for AI, cloud, DevOps, and security engineers.

The latest Agents SDK release adds support for internal hostnames that the built‑in browser can resolve directly to an agent’s Durable Object. By assigning names such as preview.internal, the browser routes requests to the agent instead of the public Internet, allowing developers to preview sandboxed services, folder assets, or other Workers without opening a public endpoint.

How Internal Hostnames Work

Each internal hostname is backed by a fetch implementation inside a Durable Object. The object can use its bindings and state, so the preview can access databases, KV stores, or other resources the agent already owns. A hostname may also include a target schema that tells the browser which port, folder, or downstream Worker to invoke. When the browser issues a request to preview.internal, the SDK intercepts the DNS lookup, maps it to the Durable Object, and runs the associated fetch handler. This mechanism is part of the browser capability itself and does not depend on any particular harness.

Integrating with a Pi Durable Agent

In a Pi Durable workflow the integration consists of three steps:

  • Browser configuration: define an internalHosts map that links hostnames to fetch logic.
  • Durable Object wiring: implement a fetchInternalHost() method that forwards the request to the appropriate sandbox port or folder.
  • Harness registration: use browserTool from agents/browser/pi to expose the browser as a tool within the Pi harness.

A minimal configuration looks like this:

const internalHosts = {
  "preview.internal": { port: 5173 },
  "api.internal": { target: "worker", binding: "API_WORKER" }
};

With Agents SDK v0.31.0 or later, the Pi Durable example can import Browser, browserRun, and the Pi‑specific tool, then register the tool during harness initialization. No additional adapters are required; the browser session API can be used to plug in custom harnesses if needed.

Operational and Security Implications

Because the preview traffic never leaves the agent’s environment, the public attack surface is unchanged. The internal hostname resolves only inside the browser sandbox, so external users cannot reach the dev server. This also means that any bindings the Durable Object holds—such as secret‑backed KV or R2—are available to the preview without exposing them to the Internet.

Practitioners should consider the following:

  • Namespace collisions: ensure internal hostnames are unique within the agent to avoid accidental routing.
  • Resource limits: the preview runs inside the same Durable Object instance, so CPU and memory quotas apply.
  • Observability: logs from the fetchInternalHost handler appear alongside normal Durable Object logs, enabling unified monitoring.
  • Adapter flexibility: while built‑in adapters exist for Pi Durable, AI SDK, and TanStack AI, teams can implement a custom tool via browser.session() without waiting for a pre‑built package.

Related CloudNinjas coverage: hands-on guides.

What This Means For Practitioners

Adopt internal hostnames when you need to test services that rely on private bindings or when exposing a temporary public URL is undesirable. Update your Agents SDK to v0.31.0+, add an internalHosts map, and wire the corresponding fetchInternalHost logic. Monitor the Durable Object for any unexpected load, and keep hostname definitions documented to avoid conflicts. This pattern provides a low‑risk, high‑fidelity preview workflow that aligns with secure development practices.

Originally published atCloudflare Developer Platform