Lock Down Where Browser Run Sessions Can Go with New Guardrails!
Hi everyone, I'm Shiichan! Today's news is about a safety feature for Browser Run, Cloudflare's headless browser service — one less thing to worry about when an agent might wander off to a site it shouldn't.
Cloudflare ChangelogWhat was announced?
Cloudflare's Changelog announced that Browser Run now supports guardrails, which restrict a browser session's HTTP and HTTPS requests to a set of permitted hostnames. You can set this up when launching a session with Puppeteer, Playwright, or the REST API.
Why it matters
Headless browser services like Browser Run get used for things like AI agent browsing and generating screenshots or PDFs from HTML you provide. But if an automated browser can reach any site, that opens the door to unintended requests to external sites, or loading arbitrary scripts and images you didn't expect. Being able to draw a clear boundary in code — "the agent doesn't go past here" — matters more and more.
What changes
With guardrails, you can now:
- Keep a browser automation workflow limited to a specific website and its subdomains
- Restrict loading to only known third-party APIs, scripts, images, and fonts
- Prevent external content from loading when generating a screenshot or PDF from HTML you provide
Here's what it looks like with Puppeteer, using a browser binding named MYBROWSER to pass in the allowed domains:
import puppeteer from "@cloudflare/puppeteer";
export async function startGuardedSession(env) {
return puppeteer.launch(env.MYBROWSER, {
guardrails: {
allowedDomains: ["example.com", "*.example.com"],
},
});
}
allowedDomains supports wildcard subdomains, so scoping a session to "this domain and its subdomains" is a one-liner.
Dive Deep
Alongside guardrails, Live View — the feature that lets you watch an active Browser Run session in real time — now supports a read-only mode. Passing { mode: "readonly" } when generating a Live View URL creates a watch-only share link: no clicking, typing, navigating, or running JavaScript. This setting only affects the person using that particular link, and doesn't change the session's own hostname restrictions.
Handy when you want to show a teammate what's happening on screen without letting them touch anything.
Wrap-up
- Browser Run now supports guardrails, restricting a session's traffic to an allowlist of hostnames
- Configure it when launching a session via Puppeteer, Playwright, or the REST API
- Live View also gets a read-only mode for watch-only screen sharing
- Great for developers who want to run AI agent browsing or HTML-to-screenshot/PDF workflows safely