You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: keep request headers off cross-origin redirects - #25
Headers passed in a screenshot request are meant for the target origin only, but Playwright reapplies the headers given to route.continue() on every redirect hop. A target page that redirected elsewhere sent those headers to the other origin too.
Header routing now uses a CDP Fetch session on the page. A CDP header override covers a single request and every redirect hop is paused again, so the headers are added only to hops on the target origin, or to the same host and port upgraded from HTTP to HTTPS, which is where a router forcing HTTPS redirects. Chromium still follows redirects itself, so the final URL, method and body handling are unchanged, and every connection still goes through the egress guard.
The logic lives in routeHeaders() in utils/egress.ts so the integration suite can drive it. New cases cover a cross-origin redirect and a same-origin chain that then leaves the origin (both fail before this change), plus a same-origin redirect that keeps the headers and ends on the redirected URL.
Verified locally with bun run lint, bun run type-check, bun run check and bun test tests/integration.
Verified end to end against a local Appwrite stack with this image: SitesConsoleClientTest screenshot tests (pixel comparison against the reference light and dark captures, which needs the routing headers to reach the router) and the Avatars screenshot tests on every client side and GraphQL. Captures of a Cloud-hosted site over HTTPS, and of a Cloud edge redirect to another origin, match 0.3.9.
Screenshot request headers are applied per request hop through CDP interception, keeping them on the configured target while Chromium follows redirects. The routing logic is shared in routeHeaders(), with integration coverage for redirect behavior and unit coverage for URL targeting.
Latest changes: The newest commit adds isTargetUrl() to retain headers on HTTP-to-HTTPS redirects to the same host when the URL ports compare equal, and adds unit cases for that rule.
Verdict
New comments
Fixed
Still open
✅ Approved
0
0
0
📂 Walkthrough · 4
File
Change
src/routes/screenshots.ts
Uses the shared routeHeaders() helper when setting up a screenshot page.
src/utils/egress.ts
Adds per-hop CDP header routing and the target URL predicate, including an HTTP-to-HTTPS upgrade exception.
tests/integration/egress.test.ts
Covers header isolation across cross-origin redirect chains and header retention on same-origin redirects.
tests/unit/egress.test.ts
Tests target URL matching, including HTTP-to-HTTPS cases.
🔇 Filtered out · 1
Findings Hansi considered but did not post.
Finding
Why
Default ports make cross-port redirects look equal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Headers passed in a screenshot request are meant for the target origin only, but Playwright reapplies the headers given to
route.continue()on every redirect hop. A target page that redirected elsewhere sent those headers to the other origin too.Header routing now uses a CDP
Fetchsession on the page. A CDP header override covers a single request and every redirect hop is paused again, so the headers are added only to hops on the target origin, or to the same host and port upgraded from HTTP to HTTPS, which is where a router forcing HTTPS redirects. Chromium still follows redirects itself, so the final URL, method and body handling are unchanged, and every connection still goes through the egress guard.The logic lives in
routeHeaders()inutils/egress.tsso the integration suite can drive it. New cases cover a cross-origin redirect and a same-origin chain that then leaves the origin (both fail before this change), plus a same-origin redirect that keeps the headers and ends on the redirected URL.Verified locally with
bun run lint,bun run type-check,bun run checkandbun test tests/integration.Verified end to end against a local Appwrite stack with this image:
SitesConsoleClientTestscreenshot tests (pixel comparison against the reference light and dark captures, which needs the routing headers to reach the router) and the Avatars screenshot tests on every client side and GraphQL. Captures of a Cloud-hosted site over HTTPS, and of a Cloud edge redirect to another origin, match0.3.9.