mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #343] [MERGED] fix: don't intercept requests in connect handler when cloudflare plugin is present #494
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#494
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/343
Author: @james-elicx
Created: 3/8/2026
Status: ✅ Merged
Merged: 3/8/2026
Merged by: @james-elicx
Base:
main← Head:j-branch-3📝 Commits (2)
783fe1etest: assert App Router wins over Pages Router connect handler with cloudflare plugine1ccd61update req.url with url📊 Changes
2 files changed (+83 additions, -0 deletions)
View changed files
📝
packages/vinext/src/index.ts(+30 -0)➕
tests/e2e/cloudflare-dev/pages-router.spec.ts(+53 -0)📄 Description
When
@cloudflare/vite-pluginis loaded alongside vinext, the connect handler inindex.tswas still attempting to handle Pages Router requests directly — running middleware, matching routes, callingcreateSSRHandler(), and invokingssrLoadModuleto render pages in the host Node.js process.This crashes with:
because
SSRCompatModuleRunnerrequires a hot channel that doesn't exist in the host process when the Cloudflare plugin is present. All rendering — both App Router and Pages Router — is supposed to go through the Cloudflare plugin's Worker entry (miniflare), not the host connect handler.The fix: after running middleware (the only thing that legitimately belongs in the host connect handler), call
next()immediately whenhasCloudflarePluginis true. This hands off to the Cloudflare plugin's connect handler, which dispatches the request to miniflare. Any middleware rewrite is written back toreq.urlfirst so miniflare sees the correct path.The
pages/index.tsxstub inapp-router-cloudflareand thecloudflare-devPlaywright project exist specifically to assert this — if the connect handler intercepts/,pages/index.tsxrenders instead ofapp/page.tsx, and the test fails.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.