mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #98] [MERGED] fix: add request validation to dev server #308
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#308
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/98
Author: @southpolesteve
Created: 2/26/2026
Status: ✅ Merged
Merged: 2/26/2026
Merged by: @southpolesteve
Base:
main← Head:fix/dev-server-validation📝 Commits (1)
acb5407fix: add request validation to dev server📊 Changes
15 files changed (+713 additions, -27 deletions)
View changed files
📝
examples/hackernews/worker/index.ts(+4 -2)📝
examples/pages-router-cloudflare/worker/index.ts(+6 -0)📝
examples/realworld-api-rest/worker/index.ts(+6 -0)📝
packages/vinext/src/deploy.ts(+8 -4)📝
packages/vinext/src/index.ts(+49 -7)📝
packages/vinext/src/server/app-dev-server.ts(+26 -5)📝
packages/vinext/src/server/app-router-entry.ts(+4 -2)➕
packages/vinext/src/server/dev-origin-check.ts(+180 -0)📝
packages/vinext/src/server/image-optimization.ts(+19 -5)📝
packages/vinext/src/server/prod-server.ts(+6 -2)📝
tests/app-router.test.ts(+85 -0)📝
tests/deploy.test.ts(+13 -0)➕
tests/dev-origin-check.test.ts(+189 -0)📝
tests/pages-router.test.ts(+60 -0)📝
tests/shims.test.ts(+58 -0)📄 Description
Summary
Adds origin verification for non-localhost requests and fixes URL sanitization in the image optimization redirect to handle backslash characters.
dev-origin-check.tsmodule validates request origins against localhost,[::1],127.0.0.1,*.localhostsubdomains, the Host header, and a configurableallowedDevOriginslist. Also checksSec-Fetch-Site/Sec-Fetch-Modeheaders. Applied to both Pages Router (connect middleware) and App Router (generated RSC entry).\to/before checking for//. Browsers and the URL constructor treat/\as//, so/\evil.comwould bypass a naive//check. Applied across all entry points: dev servers, prod servers, worker entries, and image optimization.originto localhost patterns when enablingpreflightContinue, preventing unintended wildcard CORS.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.