mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #278] [MERGED] fix: validate request origin in dev server before Vite serves content #437
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#437
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/278
Author: @southpolesteve
Created: 3/6/2026
Status: ✅ Merged
Merged: 3/6/2026
Merged by: @southpolesteve
Base:
main← Head:fix/dev-server-request-validation📝 Commits (2)
1982b0efix: validate request origin in dev server before Vite serves contentee3eef5refactor: use shared validateDevRequest() in pre-Vite middleware📊 Changes
3 files changed (+204 additions, -4 deletions)
View changed files
📝
packages/vinext/src/index.ts(+41 -4)📝
tests/app-router.test.ts(+82 -0)📝
tests/pages-router.test.ts(+81 -0)📄 Description
Summary
configureServerbody so it runs before Vite's built-in file-serving middleware. Previously, all request handling was registered in the returned function (post-middleware position), meaning Vite's internal middleware served/@*,/__vite*, and/node_modules*paths before any validation ran.originto localhost variants (127.0.0.1,[::1],*.localhost) so cross-origin pages cannot read dev server responses.Sec-Fetch-Site: cross-sitecheck as defense-in-depth for no-cors request types that may not send anOriginheader._vinext/imageendpoint redirects to internal Vite paths (/@*,/__vite*,/node_modules*).Test coverage
Added regression tests for both App Router and Pages Router dev servers covering:
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.