Add custom HTTP header support to Playwright tests for firewall bypass#1891
Add custom HTTP header support to Playwright tests for firewall bypass#1891simonknittel merged 3 commits intodevelopfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
… bypass Co-authored-by: simonknittel <8451099+simonknittel@users.noreply.github.com>
Co-authored-by: simonknittel <8451099+simonknittel@users.noreply.github.com>
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for custom HTTP headers in Playwright tests to bypass firewall restrictions. The implementation uses environment variables to configure optional header name-value pairs that are injected into all test requests.
Changes:
- Added environment variable configuration for custom HTTP header name and value
- Implemented header validation and conditional injection in Playwright config
- Updated GitHub Actions workflow to pass header credentials from repository variables and secrets
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pnpm-monorepo/apps/playwright/playwright.config.ts | Adds header validation logic and conditional extraHTTPHeaders injection |
| pnpm-monorepo/apps/playwright/.env.example | Documents new environment variables for header configuration |
| .github/workflows/playwright-tests.yml | Passes header name from Variables and value from Secrets to test execution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Basic validation: HTTP header names should be alphanumeric with hyphens/underscores | ||
| if (!/^[a-zA-Z0-9_-]+$/.test(headerName)) { | ||
| throw new Error(`Invalid HTTP header name: ${headerName}. Header names must contain only alphanumeric characters, hyphens, and underscores.`); |
There was a problem hiding this comment.
The header name validation regex allows underscores, but RFC 7230 specifies that HTTP header field names should only contain alphanumeric characters and hyphens. Underscores in header names can cause compatibility issues with some HTTP servers and proxies. Consider removing _ from the regex pattern or documenting this deviation from the standard.
| // Basic validation: HTTP header names should be alphanumeric with hyphens/underscores | |
| if (!/^[a-zA-Z0-9_-]+$/.test(headerName)) { | |
| throw new Error(`Invalid HTTP header name: ${headerName}. Header names must contain only alphanumeric characters, hyphens, and underscores.`); | |
| // Basic validation: HTTP header names should be alphanumeric with optional hyphens | |
| if (!/^[A-Za-z0-9-]+$/.test(headerName)) { | |
| throw new Error(`Invalid HTTP header name: ${headerName}. Header names must contain only alphanumeric characters and hyphens.`); |



Playwright tests are blocked by firewall. This adds configurable custom HTTP headers to requests for bypass authentication.
Changes
PLAYWRIGHT_CUSTOM_HEADER_NAMEandPLAYWRIGHT_CUSTOM_HEADER_VALUEin.env.exampleextraHTTPHeaderswhen both vars present, validates header name format (alphanumeric, hyphens, underscores only)Usage
Local development via
.env:CI/CD: Set
PLAYWRIGHT_CUSTOM_HEADER_NAMEas Repository Variable andPLAYWRIGHT_CUSTOM_HEADER_VALUEas Repository Secret.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.