mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #47] [CLOSED] fix: honor has/missing conditions in next.config headers #268
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#268
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/47
Author: @ibruno
Created: 2/25/2026
Status: ❌ Closed
Base:
main← Head:fix/config-headers-has-missing📝 Commits (2)
a7294e1fix: honor has/missing conditions in next.config headers27939f4fix: apply has/missing config headers in pages-router dev📊 Changes
11 files changed (+244 additions, -40 deletions)
View changed files
📝
packages/vinext/src/config/config-matchers.ts(+9 -0)📝
packages/vinext/src/config/next-config.ts(+2 -0)📝
packages/vinext/src/index.ts(+42 -26)📝
packages/vinext/src/server/app-dev-server.ts(+9 -3)📝
packages/vinext/src/server/prod-server.ts(+1 -1)📝
tests/app-router.test.ts(+12 -0)📝
tests/e2e/app-router/config-redirect.spec.ts(+11 -10)📝
tests/fixtures/app-basic/next.config.ts(+11 -0)📝
tests/fixtures/pages-basic/next.config.mjs(+20 -0)📝
tests/pages-router.test.ts(+28 -0)📝
tests/shims.test.ts(+99 -0)📄 Description
Summary
next.config.headers()was ignoringhas/missingconditions and applying headers based only onsource.This PR fixes that to align behavior with Next.js.
Changes
hasandmissingsupport to theNextHeadertype.matchHeaders(...)to evaluatehas/missingusingRequestContext.RequestContextin the production path (prod-server) when applying config headers.app-dev-server).matchHeaderswithhas/missing.app-router.test.ts.fixmeforconfig headers with has/missing conditions.tests/fixtures/app-basic/next.config.tswithhas/missingheader rules.Why this matters
Without this fix, conditional headers (for example cookie-gated headers) can be applied to the wrong requests, causing incorrect behavior and a compatibility gap with Next.js.
Validation
pnpm run lintpnpm run typecheckpnpm run buildpnpm testpnpm run test:e2e(passed; 1 test was flaky and passed on retry)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.