How to Configure Playwright Proxy Setup

Published
Length
3 min read

Luis Felipe Dias

All posts

A playwright proxy setup controls how automated browsers send traffic to web servers. You set it up safely by defining forward server rules and scoped login keys. Teams use browser automation to test web apps and check regional pages. Routing this traffic through an intermediate server controls where requests leave your network. It also helps teams test firewall rules and geo-blocked web pages. Without clear setup rules, test runners might expose internal network addresses or static passwords.

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

A playwright proxy setup controls how automated browsers send traffic to web servers. You set it up safely by defining forward server rules and scoped login keys.

Teams use browser automation to test web apps and check regional pages. Routing this traffic through an intermediate server controls where requests leave your network. It also helps teams test firewall rules and geo-blocked web pages. Without clear setup rules, test runners might expose internal network addresses or static passwords.

How a playwright proxy setup works in test runs

Playwright lets you define routing rules at two main levels in your test suite. You can set a global forward server when you launch the main browser instance. Or you can set specific routing rules for each isolated browser context. Context-level routing is faster because you share one browser across many test cases.

This setup affects both local developer machines and automated build runners. When a test starts, the browser sends web requests to your chosen intermediate server. That server forwards the request to the final web app and returns the response. You can also list internal domains that should bypass the intermediate server directly.

Safe defaults are vital when you set up these routing rules for your team. Never write plain text usernames or passwords inside your test scripts. Pull all login keys from secure secret stores at run time instead. Always bypass the external routing server when tests talk to local test databases. Set strict timeouts so hung network requests fail fast and do not stall builds.

Scoping browser contexts and network rules

Large test suites often need different network paths for different test groups. One test might check how a web app loads from a European address. The next test might check how the same app handles an internal admin role. Launching a brand new browser for every single test slows down your build pipeline.

Browser contexts solve this speed problem for engineering teams. Each context acts like a fresh browser profile with its own cookies and routing path. You start one main browser process and spin up lightweight contexts for each test. When a test finishes, you close the context and clear its network state.

Database Proxy (ProxySQL, PgBouncer) + Right to Erasure Implementation: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

You should also restrict which hosts the browser can reach during a test run. Many web apps load third-party scripts, fonts, or tracking pixels on every page. Routing all that extra traffic through a paid external server wastes money and bandwidth. Set up host filter rules in your test runner to block unneeded external domains. This keeps test runs fast, cheap, and focused on your own web app.

Checking traffic logs and fixing static key gaps

Before you run your full test suite, check that traffic follows your routing rules. Have your test browser open a simple IP check page during a setup step. Read the response to confirm the outbound address matches your expected forward server. You should also check your server logs to confirm that bypass rules work right.

Even with good tests, static routing setups leave big security gaps for teams. Once a browser session logs in, static settings cannot see what happens inside the page. Test scripts often hold long-lived login keys that work across many runs. If a build runner leaks those keys, an attacker can use your network path.

Standard network logs only show domain names and basic status codes for encrypted traffic. They do not link specific browser actions to an individual developer or build job. Teams also struggle to keep sensitive data out of test screenshots and trace files. When tests read real user pages, emails or card numbers can land in build logs. You need strong access controls and data masking to protect these test systems.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can I use a different routing server for each test case?

Yes, you can assign a unique routing server to each isolated browser context. You must set a placeholder server at launch time on some desktop systems first. After launch, each new context can use its own server address and login keys.

How do I keep test scripts from leaking routing passwords?

Store all server usernames and passwords in your build runner secret store. Pass those values into the test process through runtime variables when the job starts. Make sure your test runner masks those secret values in all console log outputs.

Why do my local app tests fail when routing is turned on?

External forward servers cannot reach local services running on your test machine. You must add local host names and internal IP ranges to your bypass list. This tells the browser to reach local test apps directly without the external server.

The query runs. The emails stay hidden.