cloudflare / vinext

fix: throw on missing middleware/proxy exports instead of failing open (#203)
* fix: throw on missing middleware/proxy exports instead of failing open Middleware and proxy files that don't export the expected function (e.g. misspelled export, wrong named export) were silently skipped, letting requests through unprotected. This matches Next.js behavior which throws a ProxyMissingExportError in the same scenario. Changes: - proxy.ts files now require 'proxy' or 'default' export - middleware.ts files now require 'middleware' or 'default' export - All 3 code paths updated (Pages dev, Pages prod, App Router) - Added resolveMiddlewareHandler() with file-type-aware validation - Ported test cases from Next.js proxy-missing-export test suite - Updated AGENTS.md: added required step to search Next.js tests Ported from Next.js: test/e2e/app-dir/proxy-missing-export/ https://github.com/vercel/next.js/blob/canary/test/e2e/app-dir/proxy-missing-export/proxy-missing-export.test.ts * fix: update export precedence test to match Next.js behavior (named > default) * fix: use ?? instead of || in generated middleware export resolution for consistency Matches the shared resolveMiddlewareHandler() which uses nullish coalescing. No behavioral difference since typeof check catches all cases, but keeps the three code paths consistent.
Steve Faulkner Steve Faulkner committed on Feb 28, 2026, 11:18 PM
Showing 7 changed files +247 additions -22 deletions
Browse files at this commit โ†’