[PR #291] [MERGED] Use append for multi-value headers in config header application #450

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

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/291
Author: @southpolesteve
Created: 3/6/2026
Status: Merged
Merged: 3/6/2026
Merged by: @southpolesteve

Base: mainHead: fix/config-headers-append-multi-value


📝 Commits (2)

  • 0fd8de4 Apply same append logic for multi-value headers in index.ts and deploy.ts
  • 43fac26 Add append logic for multi-value config headers in prod-server.ts and app-dev-server.ts

📊 Changes

6 files changed (+79 additions, -4 deletions)

View changed files

📝 packages/vinext/src/deploy.ts (+11 -1)
📝 packages/vinext/src/index.ts (+25 -1)
📝 packages/vinext/src/server/app-dev-server.ts (+10 -1)
📝 packages/vinext/src/server/prod-server.ts (+18 -1)
📝 tests/fixtures/pages-basic/next.config.mjs (+5 -0)
📝 tests/pages-router.test.ts (+10 -0)

📄 Description

Summary

  • Config headers from next.config.js were applied using set(), which replaces any existing header with the same key. For multi-value headers like Vary and Set-Cookie, this destroys previously set values. For example, a config header setting Vary: Accept-Language would replace the existing Vary: RSC, Accept header, breaking CDN caching behavior.
  • Changed to use append() for Vary and Set-Cookie headers so values accumulate correctly. All other headers continue to use set() (override is the correct behavior for single-value headers).

Changes

  • packages/vinext/src/server/app-dev-server.ts: Config header application in handler() wrapper uses append() for Vary and Set-Cookie, set() for all others.
  • packages/vinext/src/server/prod-server.ts: Config header merging into middlewareHeaders object concatenates Vary and Set-Cookie values instead of overwriting.
  • tests/fixtures/pages-basic/next.config.mjs: Added a Vary config header rule on /ssr.
  • tests/pages-router.test.ts: New test verifying Vary config header appears in the response.

🔄 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/291 **Author:** [@southpolesteve](https://github.com/southpolesteve) **Created:** 3/6/2026 **Status:** ✅ Merged **Merged:** 3/6/2026 **Merged by:** [@southpolesteve](https://github.com/southpolesteve) **Base:** `main` ← **Head:** `fix/config-headers-append-multi-value` --- ### 📝 Commits (2) - [`0fd8de4`](https://github.com/cloudflare/vinext/commit/0fd8de4d2bc1c928744a0e98a477865ca43a581d) Apply same append logic for multi-value headers in index.ts and deploy.ts - [`43fac26`](https://github.com/cloudflare/vinext/commit/43fac267fc057c7eaeecb560de3ab7e22e491670) Add append logic for multi-value config headers in prod-server.ts and app-dev-server.ts ### 📊 Changes **6 files changed** (+79 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/deploy.ts` (+11 -1) 📝 `packages/vinext/src/index.ts` (+25 -1) 📝 `packages/vinext/src/server/app-dev-server.ts` (+10 -1) 📝 `packages/vinext/src/server/prod-server.ts` (+18 -1) 📝 `tests/fixtures/pages-basic/next.config.mjs` (+5 -0) 📝 `tests/pages-router.test.ts` (+10 -0) </details> ### 📄 Description ## Summary - Config headers from `next.config.js` were applied using `set()`, which replaces any existing header with the same key. For multi-value headers like `Vary` and `Set-Cookie`, this destroys previously set values. For example, a config header setting `Vary: Accept-Language` would replace the existing `Vary: RSC, Accept` header, breaking CDN caching behavior. - Changed to use `append()` for `Vary` and `Set-Cookie` headers so values accumulate correctly. All other headers continue to use `set()` (override is the correct behavior for single-value headers). ## Changes - `packages/vinext/src/server/app-dev-server.ts`: Config header application in handler() wrapper uses `append()` for Vary and Set-Cookie, `set()` for all others. - `packages/vinext/src/server/prod-server.ts`: Config header merging into middlewareHeaders object concatenates Vary and Set-Cookie values instead of overwriting. - `tests/fixtures/pages-basic/next.config.mjs`: Added a Vary config header rule on `/ssr`. - `tests/pages-router.test.ts`: New test verifying Vary config header appears in the response. --- <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:52 +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#450
No description provided.