How to Configure Playwright Proxy Settings
Playwright proxy settings route browser test traffic through an outbound network server. You set them up at the global browser level or per browser context. Teams use these settings to test geo-blocked pages and reach private staging apps. A good setup keeps test keys out of source code and limits network paths. How playwright proxy settings work in browser tests Playwright lets you define network routing when you launch a browser instance. Every page that opens inside that browser then shar
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.
Playwright proxy settings route browser test traffic through an outbound network server. You set them up at the global browser level or per browser context.
Teams use these settings to test geo-blocked pages and reach private staging apps. A good setup keeps test keys out of source code and limits network paths.
How playwright proxy settings work in browser tests
Playwright lets you define network routing when you launch a browser instance. Every page that opens inside that browser then shares the same outbound route. You can also define a separate route for each isolated browser context. Context-level routing helps when one test suite checks multiple regions at the same time.
Each browser context acts like a fresh user profile with its own cookies. When you attach a route to a context, only that user profile uses it. Other tests in the same run can use a different route or direct traffic. This saves memory because you launch one browser binary for many isolated contexts.
A standard setup needs a server address and optional login details. You can also define a bypass list for internal hosts that need direct paths. Safe defaults always pull the server address and login keys from secret stores. Never write usernames or passwords in plain text inside your test runner files.
How to handle login keys and bypass rules
Many outbound servers require a username and password before they forward any packets. If you store these login keys in git, anyone with repo access sees them. CI logs can also leak these keys if a test fails and prints settings. Always load your login details from secret variables during the test run.
Bypass rules tell the browser which domains should skip the outbound server. Teams often bypass local hosts and internal staging domains to speed up test runs. If you make the bypass rule too broad, traffic may leak outside your route. Keep the bypass list strict and test each domain rule before you ship it.
Database Proxy (ProxySQL, PgBouncer) + Right to Erasure Implementation: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Some outbound servers use custom root certificates to inspect encrypted traffic on the wire. Browsers reject these custom certificates by default and fail the test run right away. You can tell the test runner to ignore HTTPS errors during staging runs. Only enable that setting on trusted networks so you do not hide real bugs.
How to check traffic and audit test runs
Before you run a full test suite, check that your route works right. Have your test script load a basic IP check page and read the response. Compare that returned address against the expected outbound server address before running app tests. This quick check stops tests from running on the wrong network path.
Network logs help your team see every request the browser makes during a test. You can capture HTTP archive files or use browser network events to log traffic. Make sure your log tool scrubs sensitive headers before it writes files to disk. Masking tools can rewrite emails, phone numbers, card numbers, or national IDs in logs.
Static browser settings only control where network packets go at the transport layer. Once a test runner logs in, static settings cannot restrict which actions it takes. A shared staging account with broad rights can still delete data or read secrets. Teams must pair network routing with strict role checks and clear audit logs.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Can I use a different outbound route for each test?
Yes, you can assign a unique route to each isolated browser context you create. This lets parallel tests use different network locations without launching extra browser binaries.
Why do my browser tests fail with certificate errors?
Inspecting servers often sign web traffic with a custom root certificate browsers do not trust. Add the custom root certificate to your runner machine or ignore HTTPS errors in staging.
How do I stop local traffic from using the outbound route?
Add localhost and loopback addresses to the bypass setting in your test setup. The browser will send traffic for those hosts straight to your local machine.
Related guides
In this post