fix(headers): preserve config Link headers alongside React preload links - #2791
Open
MaxtuneLee wants to merge 2 commits into
Open
fix(headers): preserve config Link headers alongside React preload links#2791MaxtuneLee wants to merge 2 commits into
MaxtuneLee wants to merge 2 commits into
Conversation
commit: |
Contributor
Performance benchmarksCompared 1 improved · 0 regressed · 5 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
MaxtuneLee
force-pushed
the
fix/config-link-header
branch
from
August 4, 2026 05:20
913d4c8 to
00d8062
Compare
MaxtuneLee
marked this pull request as ready for review
August 4, 2026 05:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2788.
Linkas an appendable response header when applying matchingnext.config.jsheaders()rules in the App Routernext/fontpreload links when a config rule contributes anotherLinkrelationProblem
App Router response finalization applies matching config headers after React has emitted preload headers. The config-header merger only appended
VaryandSet-Cookie; for every other existing header name it skipped the config value. As a result, a React ornext/fontpreloadLinkcaused an unrelated configLink, such asrel="describedby", to disappear from the final response.Linkis a list-valued field, so the configured relation and framework preload can coexist in one comma-combined field or separate fields. Next.js preserves both values.Fix
Include
linkin the set of response headers that useHeaders.append()during App Router config-header application. The existing precedence rules for singular response headers are unchanged.The fixture reproduces the reported behavior with:
ReactDOM.preload("/agent-test.woff2", ...)next.config.tssettingLink: </llms.txt>; rel="describedby"; type="text/plain"Both relations are now present in development and production responses.
This change is limited to config-header application. The separate ISR cache provenance issue reported in #2782 is not changed here.
Test plans
Add new finalizer regression test:
After the fix, the following checks pass: