Skip to content

fix: support has/missing conditions on config headers and fix glob exclude patterns in routing#134

Closed
erayack wants to merge 1 commit intocloudflare:mainfrom
erayack:fix/config-headers-has-missing-and-glob-routing
Closed

fix: support has/missing conditions on config headers and fix glob exclude patterns in routing#134
erayack wants to merge 1 commit intocloudflare:mainfrom
erayack:fix/config-headers-has-missing-and-glob-routing

Conversation

@erayack
Copy link
Contributor

@erayack erayack commented Feb 26, 2026

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

@southpolesteve
Copy link
Collaborator

Hey @erayack, thanks for this PR! The core has/missing fix for config headers was already merged in #48, so there's overlap there. But your PR had several other valuable improvements that we've extracted into separate PRs (with you as commit author):

Going to close this PR since the individual pieces are covered, but really appreciate the contribution. Each of those PRs credits you as the commit author.

@erayack
Copy link
Contributor Author

erayack commented Mar 1, 2026

Sounds great! Thanks for splitting these up and for the credit on the separate PRs. Glad I could help! @southpolesteve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants