Skip to content

fix(vinext): run middleware and next.config rules in Pages Router apps - #742

Draft
magurotuna wants to merge 1 commit into
voidzero-dev:mainfrom
magurotuna:vinext-nextjs-support
Draft

magurotuna wants to merge 1 commit into
voidzero-dev:mainfrom
magurotuna:vinext-nextjs-support

Conversation

@magurotuna

Copy link
Copy Markdown
Member

On current main, vinext Pages Router apps skip middleware.ts and the redirects(), rewrites() and headers() rules in next.config. For instance, auth checks in middleware never run. This is because Void's generated entry calls vinext's renderPage() and handleApiRoute() directly, which skips vinext's request handling.

With this PR, the generated entry uses vinext/server/pages-router-entry, as the App Router path already uses vinext's own entry.

Request Before After
Redirect in middleware.ts 404 307
Redirect in next.config 404 307
Header from middleware.ts or next.config missing present

Files in public/ are still served without running middleware. This is unchanged from Void's current behavior, but differs from Next.js.

Tests: playground/vinext-pages gains a middleware.ts and a next.config.mjs, each with a redirect, a rewrite and a header. They are checked in vp dev and in a built Worker.

Not tested on live Cloudflare.

AI disclosure: I used Claude to write code and this PR. I reviewed them.

Void's generated Pages Router worker entry called vinext's renderPage and
handleApiRoute directly, which skipped middleware and next.config
redirects, rewrites and headers. Auth checks in middleware were bypassed.

Use vinext's own Pages Router entry (vinext/server/pages-router-entry), as
the App Router path already does. Void's cron and queue wrapper is unchanged.

Add middleware and next.config fixtures to playground/vinext-pages, with dev
and Miniflare build tests (both plugin orders) for redirects, rewrites and
headers.

This branch has not been deployed

No deployments
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.

1 participant