mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #1071] [MERGED] refactor(server): dedupe forbidden response construction #1068
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#1068
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/1071
Author: @james-elicx
Created: 5/5/2026
Status: ✅ Merged
Merged: 5/5/2026
Merged by: @james-elicx
Base:
main← Head:refactor/dedupe-forbidden-response📝 Commits (1)
501cfa7refactor(server): dedupe forbidden response construction📊 Changes
2 files changed (+21 additions, -7 deletions)
View changed files
📝
packages/vinext/src/server/dev-origin-check.ts(+8 -4)📝
packages/vinext/src/server/request-pipeline.ts(+13 -3)📄 Description
Summary
new Response("Forbidden", { status: 403, headers: { "Content-Type": "text/plain" } })was repeated 7 times across two server files.forbiddenResponse()helper inrequest-pipeline.tsand replaces the 3 byte-identical call sites invalidateCsrfOrigin.generateDevOriginCheckCode()— which emits inline JS that runs in the RSC Vite environment and cannot import TS modules — introduces a local__forbidden()helper inside the generated code so the duplication is eliminated there too.Touched files
packages/vinext/src/server/request-pipeline.ts— adds exportedforbiddenResponse(); replaces 3 inline literals.packages/vinext/src/server/dev-origin-check.ts— emits a local__forbidden()helper inside the codegen template; replaces 4 inline literals in the generated JS.Test plan
pnpm vp test run tests/app-router.test.ts tests/pages-router.test.ts— 508 tests pass. (One unrelatedafterAllcleanup-hook timeout under heavy concurrent load; reruns of the touched suite, includingPages Router allowedDevOrigins config, all pass.)pnpm fmt:check— clean.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.