upstream-response-headers.mjs
25 lines 816 B
Raw
sha256:7fe782411f3a68b39f17777b274349b30752365c13438b26bfd602c687de2c65 feat(web): rebrand Parentier family to Ourware on landing Human minor ⚠ breaking 22 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:7fe782411f3a68b39f17777b274349b30752365c13438b26bfd602c687de2c65 feat(web): rebrand Parentier family to Ourware on landing Human minor 22 days ago