[PR #265] [CLOSED] fix: strip content-encoding/content-length from proxied rewrite responses #427

Closed
opened 2026-05-06 12:39:45 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/265
Author: @17hz
Created: 3/5/2026
Status: Closed

Base: mainHead: fix/content-encoding-proxy


📝 Commits (1)

  • eefc283 fix: strip content-encoding/content-length from proxied rewrite responses

📊 Changes

2 files changed (+7 additions, -2 deletions)

View changed files

📝 packages/vinext/src/config/config-matchers.ts (+6 -1)
📝 packages/vinext/src/server/app-dev-server.ts (+1 -1)

📄 Description

Fixes #263

Problem

proxyExternalRequest and __proxyExternalRequest forward upstream content-encoding and content-length headers to the browser as-is. However, Node.js fetch() automatically decompresses response bodies (gzip, br, deflate), so these headers no longer match the actual body. The browser sees content-encoding: gzip, attempts to decompress the already-decompressed body, and fails with ERR_CONTENT_DECODING_FAILED.

Fix

Strip content-encoding and content-length from upstream response headers before forwarding to the client. Applied in both:

  • config-matchers.tsproxyExternalRequest (used by prod server)
  • app-dev-server.ts__proxyExternalRequest (inlined in dev server virtual module)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/265 **Author:** [@17hz](https://github.com/17hz) **Created:** 3/5/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/content-encoding-proxy` --- ### 📝 Commits (1) - [`eefc283`](https://github.com/cloudflare/vinext/commit/eefc2839d49cdd3672e1da6a4d82cf10302b7d91) fix: strip content-encoding/content-length from proxied rewrite responses ### 📊 Changes **2 files changed** (+7 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/config/config-matchers.ts` (+6 -1) 📝 `packages/vinext/src/server/app-dev-server.ts` (+1 -1) </details> ### 📄 Description Fixes #263 ## Problem `proxyExternalRequest` and `__proxyExternalRequest` forward upstream `content-encoding` and `content-length` headers to the browser as-is. However, Node.js `fetch()` automatically decompresses response bodies (gzip, br, deflate), so these headers no longer match the actual body. The browser sees `content-encoding: gzip`, attempts to decompress the already-decompressed body, and fails with `ERR_CONTENT_DECODING_FAILED`. ## Fix Strip `content-encoding` and `content-length` from upstream response headers before forwarding to the client. Applied in both: - `config-matchers.ts` — `proxyExternalRequest` (used by prod server) - `app-dev-server.ts` — `__proxyExternalRequest` (inlined in dev server virtual module) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:39:45 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#427
No description provided.