[PR #213] [MERGED] fix: make RequestContext required on matchHeaders/matchRedirect/matchRewrite #391

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

📋 Pull Request Information

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

Base: mainHead: fix/require-ctx-in-matchers


📝 Commits (1)

  • 888fcde fix: make RequestContext required on matchHeaders/matchRedirect/matchRewrite

📊 Changes

4 files changed (+37 additions, -32 deletions)

View changed files

📝 packages/vinext/src/config/config-matchers.ts (+15 -16)
📝 packages/vinext/src/deploy.ts (+1 -1)
📝 packages/vinext/src/index.ts (+3 -3)
📝 tests/shims.test.ts (+18 -12)

📄 Description

Summary

  • Makes ctx: RequestContext a required parameter on matchHeaders, matchRedirect, and matchRewrite in config-matchers.ts (and their wrapper functions in index.ts)
  • Fixes deploy.ts where matchHeaders was called without reqCtx (the only call site missing it)
  • Updates tests to pass a minimal RequestContext instead of relying on the previously optional parameter

Why

Next.js always has request context when evaluating has/missing conditions. There is no code path where these matchers run without a request. Making ctx required:

  1. Eliminates the ambiguous "what if ctx is missing?" question (previously, conditional rules were silently applied without checking conditions)
  2. Catches missing context at compile time instead of causing silent behavioral bugs at runtime
  3. Matches Next.js semantics, where matchHas() takes req as a required parameter

Extracted from #134 by @erayack.


🔄 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/213 **Author:** [@southpolesteve](https://github.com/southpolesteve) **Created:** 3/1/2026 **Status:** ✅ Merged **Merged:** 3/1/2026 **Merged by:** [@southpolesteve](https://github.com/southpolesteve) **Base:** `main` ← **Head:** `fix/require-ctx-in-matchers` --- ### 📝 Commits (1) - [`888fcde`](https://github.com/cloudflare/vinext/commit/888fcdec6d731d3d3f4fba8715b02385732a0f18) fix: make RequestContext required on matchHeaders/matchRedirect/matchRewrite ### 📊 Changes **4 files changed** (+37 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/config/config-matchers.ts` (+15 -16) 📝 `packages/vinext/src/deploy.ts` (+1 -1) 📝 `packages/vinext/src/index.ts` (+3 -3) 📝 `tests/shims.test.ts` (+18 -12) </details> ### 📄 Description ## Summary - Makes `ctx: RequestContext` a required parameter on `matchHeaders`, `matchRedirect`, and `matchRewrite` in `config-matchers.ts` (and their wrapper functions in `index.ts`) - Fixes `deploy.ts` where `matchHeaders` was called without `reqCtx` (the only call site missing it) - Updates tests to pass a minimal `RequestContext` instead of relying on the previously optional parameter ## Why Next.js always has request context when evaluating `has`/`missing` conditions. There is no code path where these matchers run without a request. Making `ctx` required: 1. Eliminates the ambiguous "what if ctx is missing?" question (previously, conditional rules were silently applied without checking conditions) 2. Catches missing context at compile time instead of causing silent behavioral bugs at runtime 3. Matches Next.js semantics, where `matchHas()` takes `req` as a required parameter Extracted from #134 by @erayack. --- <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:35 +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#391
No description provided.