Skip to content

feat: add custom HTTP headers support#17

Merged
lackeyjb merged 5 commits intomainfrom
feat/custom-headers
Dec 2, 2025
Merged

feat: add custom HTTP headers support#17
lackeyjb merged 5 commits intomainfrom
feat/custom-headers

Conversation

@lackeyjb
Copy link
Owner

@lackeyjb lackeyjb commented Dec 2, 2025

Summary

Adds support for custom HTTP headers on all Playwright requests via environment variables. This enables backends to detect automated/LLM traffic and return optimized responses.

Closes #7

Configuration

Single header (common case):

PW_HEADER_NAME=X-Automated-By PW_HEADER_VALUE=playwright-skill

Multiple headers (JSON):

PW_EXTRA_HEADERS='{"X-Automated-By":"playwright-skill","X-Debug":"true"}'

Changes

  • helpers.js: Add getExtraHeadersFromEnv() and update createContext() to merge env headers
  • run.js: Inject getContextOptionsWithHeaders() utility in wrapper for raw Playwright API usage
  • SKILL.md: Document custom headers feature
  • API_REFERENCE.md: Add headers API reference
  • Bump version to 4.1.0

Test plan

  • Set PW_HEADER_NAME + PW_HEADER_VALUE and verify headers sent
  • Set PW_EXTRA_HEADERS JSON and verify multiple headers sent
  • Verify headers not sent when env vars not configured (backward compatible)
  • Verify options.extraHTTPHeaders takes precedence over env vars

@lackeyjb lackeyjb merged commit c82d6e5 into main Dec 2, 2025
@lackeyjb lackeyjb deleted the feat/custom-headers branch December 2, 2025 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom headers for all HTTP(s) requests

1 participant

Comments