[PR #272] [MERGED] fix: strip content-encoding and content-length from proxied responses #432

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

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/272
Author: @MumuTW
Created: 3/5/2026
Status: Merged
Merged: 3/7/2026
Merged by: @southpolesteve

Base: mainHead: fix/double-decompression-proxy-263


📝 Commits (3)

  • cb69561 fix: strip content-encoding and content-length from proxied responses (#263)
  • d6165cd fix: gate proxy header stripping to Node runtime
  • ac2f19f fix: guard content-encoding stripping to Node runtime in config-matchers

📊 Changes

4 files changed (+94 additions, -4 deletions)

View changed files

📝 packages/vinext/src/config/config-matchers.ts (+11 -3)
📝 packages/vinext/src/server/app-dev-server.ts (+10 -1)
📝 tests/app-router.test.ts (+37 -0)
📝 tests/shims.test.ts (+36 -0)

📄 Description

Summary

Fixes #263.

Node.js fetch() auto-decompresses responses (gzip, br, etc.), but the proxy in proxyExternalRequest was forwarding the original content-encoding and content-length headers unchanged. This caused the browser to attempt a second decompression on the already-decoded body, resulting in ERR_CONTENT_DECODING_FAILED.

Changes

  • packages/vinext/src/config/config-matchers.ts — Strip content-encoding and content-length headers from upstream responses in proxyExternalRequest.
  • packages/vinext/src/server/app-dev-server.ts — Apply the same fix to the inline __proxyExternalRequest dev-server helper.
  • tests/shims.test.ts — Add test verifying that content-encoding and content-length are stripped while other headers are preserved.

Test plan

  • New unit test: strips content-encoding and content-length from proxied response to avoid double-decompression
  • Manual verification with a gzip-encoded upstream behind the proxy

🔄 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/272 **Author:** [@MumuTW](https://github.com/MumuTW) **Created:** 3/5/2026 **Status:** ✅ Merged **Merged:** 3/7/2026 **Merged by:** [@southpolesteve](https://github.com/southpolesteve) **Base:** `main` ← **Head:** `fix/double-decompression-proxy-263` --- ### 📝 Commits (3) - [`cb69561`](https://github.com/cloudflare/vinext/commit/cb695611cab5b00b43d9dbd4badd54d893a703e4) fix: strip content-encoding and content-length from proxied responses (#263) - [`d6165cd`](https://github.com/cloudflare/vinext/commit/d6165cd411b61a3427dfdeb5e608bbecd07b67fc) fix: gate proxy header stripping to Node runtime - [`ac2f19f`](https://github.com/cloudflare/vinext/commit/ac2f19f3bf098d4a6ff734d942cf7b4fe802e20c) fix: guard content-encoding stripping to Node runtime in config-matchers ### 📊 Changes **4 files changed** (+94 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/config/config-matchers.ts` (+11 -3) 📝 `packages/vinext/src/server/app-dev-server.ts` (+10 -1) 📝 `tests/app-router.test.ts` (+37 -0) 📝 `tests/shims.test.ts` (+36 -0) </details> ### 📄 Description ## Summary Fixes #263. Node.js `fetch()` auto-decompresses responses (gzip, br, etc.), but the proxy in `proxyExternalRequest` was forwarding the original `content-encoding` and `content-length` headers unchanged. This caused the browser to attempt a second decompression on the already-decoded body, resulting in `ERR_CONTENT_DECODING_FAILED`. ## Changes - **`packages/vinext/src/config/config-matchers.ts`** — Strip `content-encoding` and `content-length` headers from upstream responses in `proxyExternalRequest`. - **`packages/vinext/src/server/app-dev-server.ts`** — Apply the same fix to the inline `__proxyExternalRequest` dev-server helper. - **`tests/shims.test.ts`** — Add test verifying that `content-encoding` and `content-length` are stripped while other headers are preserved. ## Test plan - [x] New unit test: `strips content-encoding and content-length from proxied response to avoid double-decompression` - [ ] Manual verification with a gzip-encoded upstream behind the proxy --- <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:47 +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#432
No description provided.