upstream-response-headers.mjs
25 lines 816 B
Raw
sha256:baa800aedf841dbf32081aa7b2befa288ac33dfc7175ac55014c55c4d8c742f9 docs: move durable-auth freeze/evidence to local developmen… Human 11 days ago
1 /**
2 * When the gateway proxies with fetch().text(), the body is already decoded.
3 * Forwarding upstream Content-Encoding (e.g. br) causes browsers to ERR_CONTENT_DECODING_FAILED.
4 */
5
6 const STRIP_FROM_UPSTREAM_DECODED_BODY = new Set([
7 'content-encoding',
8 'content-length',
9 'transfer-encoding',
10 'connection',
11 'access-control-allow-origin',
12 'access-control-allow-methods',
13 'access-control-allow-headers',
14 'access-control-allow-credentials',
15 'access-control-expose-headers',
16 'access-control-max-age',
17 ]);
18
19 /**
20 * @param {Iterable<[string, string]>} entries - upstream Response.headers entries
21 * @returns {[string, string][]}
22 */
23 export function filterUpstreamResponseHeadersForDecodedBody(entries) {
24 return [...entries].filter(([k]) => !STRIP_FROM_UPSTREAM_DECODED_BODY.has(k.toLowerCase()));
25 }
File History 1 commit
sha256:baa800aedf841dbf32081aa7b2befa288ac33dfc7175ac55014c55c4d8c742f9 docs: move durable-auth freeze/evidence to local developmen… Human 11 days ago