[PR #134] [CLOSED] fix: support has/missing conditions on config headers and fix glob exclude patterns in routing #340

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

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/134
Author: @erayack
Created: 2/26/2026
Status: Closed

Base: mainHead: fix/config-headers-has-missing-and-glob-routing


📝 Commits (1)

  • 50f84e7 fix: support has/missing conditions on config headers and fix glob exclude patterns in routing

📊 Changes

11 files changed (+184 additions, -27 deletions)

View changed files

📝 packages/vinext/src/config/config-matchers.ts (+9 -0)
📝 packages/vinext/src/config/next-config.ts (+29 -1)
📝 packages/vinext/src/routing/app-router.ts (+6 -2)
📝 packages/vinext/src/routing/pages-router.ts (+4 -1)
📝 packages/vinext/src/server/app-dev-server.ts (+10 -3)
📝 packages/vinext/src/server/prod-server.ts (+1 -1)
📝 tests/e2e/app-router/config-redirect.spec.ts (+24 -10)
📝 tests/e2e/pages-router/head-and-dynamic.spec.ts (+6 -2)
📝 tests/fixtures/app-basic/next.config.ts (+12 -0)
📝 tests/nextjs-compat/TRACKING.md (+6 -7)
📝 tests/shims.test.ts (+77 -0)

📄 Description

Summary

Fixes config headers() matcher parity with redirects/rewrites by adding has/missing condition evaluation, and hardens behavior to fail closed when conditional header rules are evaluated without request context.

What changed

  • Added has/missing support to config header matching in shared matcher and dev server path.
  • Passed request context into header matching in prod server.
  • Extended NextHeader typing to include has and missing.
  • Added/updated tests:
    • Enabled E2E coverage for config headers with cookie has/missing conditions.
    • Added unit tests for matchHeaders, including no-context fail-closed behavior.
    • Fixed a flaky pages-router E2E (next/dynamic) by replacing ambiguous text locator with an exact heading-role locator.

Why

Previously, headers() rules only matched source and ignored request-context conditions, causing behavior mismatch with redirects/rewrites and Next.js compatibility gaps.

Validation

pnpm test tests/shims.test.ts -t "matchHeaders"
pnpm exec playwright test tests/e2e/app-router/config-redirect.spec.ts --grep "config headers with has/missing conditions"
CI=true PLAYWRIGHT_PROJECT=pages-router pnpm exec playwright test tests/e2e/pages-router/head-and-dynamic.spec.ts

🔄 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/134 **Author:** [@erayack](https://github.com/erayack) **Created:** 2/26/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/config-headers-has-missing-and-glob-routing` --- ### 📝 Commits (1) - [`50f84e7`](https://github.com/cloudflare/vinext/commit/50f84e76a9a7f2d2c256e8c6a2c4e87de8d6607d) fix: support has/missing conditions on config headers and fix glob exclude patterns in routing ### 📊 Changes **11 files changed** (+184 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/config/config-matchers.ts` (+9 -0) 📝 `packages/vinext/src/config/next-config.ts` (+29 -1) 📝 `packages/vinext/src/routing/app-router.ts` (+6 -2) 📝 `packages/vinext/src/routing/pages-router.ts` (+4 -1) 📝 `packages/vinext/src/server/app-dev-server.ts` (+10 -3) 📝 `packages/vinext/src/server/prod-server.ts` (+1 -1) 📝 `tests/e2e/app-router/config-redirect.spec.ts` (+24 -10) 📝 `tests/e2e/pages-router/head-and-dynamic.spec.ts` (+6 -2) 📝 `tests/fixtures/app-basic/next.config.ts` (+12 -0) 📝 `tests/nextjs-compat/TRACKING.md` (+6 -7) 📝 `tests/shims.test.ts` (+77 -0) </details> ### 📄 Description ## Summary Fixes config `headers()` matcher parity with redirects/rewrites by adding `has`/`missing` condition evaluation, and hardens behavior to fail closed when conditional header rules are evaluated without request context. ## What changed - Added `has`/`missing` support to config header matching in shared matcher and dev server path. - Passed request context into header matching in prod server. - Extended `NextHeader` typing to include `has` and `missing`. - Added/updated tests: - Enabled E2E coverage for config headers with cookie `has`/`missing` conditions. - Added unit tests for `matchHeaders`, including no-context fail-closed behavior. - Fixed a flaky pages-router E2E (`next/dynamic`) by replacing ambiguous text locator with an exact heading-role locator. ## Why Previously, `headers()` rules only matched `source` and ignored request-context conditions, causing behavior mismatch with redirects/rewrites and Next.js compatibility gaps. ## Validation ```bash pnpm test tests/shims.test.ts -t "matchHeaders" pnpm exec playwright test tests/e2e/app-router/config-redirect.spec.ts --grep "config headers with has/missing conditions" CI=true PLAYWRIGHT_PROJECT=pages-router pnpm exec playwright test tests/e2e/pages-router/head-and-dynamic.spec.ts ``` --- <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:18 +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#340
No description provided.