Skip to content

Commit

Permalink
chore: update documentation in response middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
AtofStryker committed Apr 30, 2024
1 parent 0d9a3c1 commit 96ee05c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/proxy/lib/http/response-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,15 @@ const MaybeSetOriginAgentClusterHeader: ResponseMiddleware = function () {

if (process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS && process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS === origin) {
// For cypress-in-cypress tests exclusively, we need to bucket all origin-agent-cluster requests
// from HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS to include Origin-Agent-Cluster=false. This has to due with changed
// from HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS to include Origin-Agent-Cluster=false. This has to do with changed
// behavior starting in Chrome 119. The new behavior works like the following:
// If a page did not request an origin-keyed agent cluster, chrome will place it in one
// anyway because a previous request went through without the Origin-Agent-Cluster=false header set.
// At time of writing, documentation detailing this behavior has not been found.

// - If the first page from an origin does not set the header,
// then no other pages from that origin will be origin-keyed, even if those other pages do set the header.
// - If the first page from an origin sets the header and is made origin-keyed,
// then all other pages from that origin will be origin-keyed whether they ask for it or not.
// To work around this, any request that matches the origin of HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS
// should set the Origin-Agent-Cluster=false header to avoid origin-keyed agent clusters for
// should set the Origin-Agent-Cluster=false header to avoid origin-keyed agent clusters.
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin-Agent-Cluster for more details.
this.res.setHeader('Origin-Agent-Cluster', '?0')
}
}
Expand Down

0 comments on commit 96ee05c

Please sign in to comment.