[PR #171] [MERGED] Align Pages Router worker entry with prod-server request handling #367

Closed
opened 2026-05-06 12:39:27 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/171
Author: @southpolesteve
Created: 2/27/2026
Status: Merged
Merged: 2/27/2026
Merged by: @southpolesteve

Base: mainHead: fix/pages-router-worker-request-handling


📝 Commits (4)

  • d951af6 Skip deploy previews for fork PRs that lack Cloudflare secrets
  • fec8d6c fix: align Pages Router worker entry with prod-server request handling
  • 7df2f50 Merge main into fix/pages-router-worker-request-handling
  • 28bd1be chore: sync pnpm-lock.yaml with upstream package.json changes

📊 Changes

7 files changed (+907 additions, -184 deletions)

View changed files

📝 examples/pages-router-cloudflare/worker/index.ts (+203 -10)
📝 examples/realworld-api-rest/worker/index.ts (+203 -10)
📝 package.json (+2 -3)
📝 packages/vinext/package.json (+4 -0)
📝 packages/vinext/src/deploy.ts (+218 -11)
📝 pnpm-lock.yaml (+151 -147)
📝 tests/deploy.test.ts (+126 -3)

📄 Description

Summary

The generated Cloudflare Worker entry for Pages Router apps (generatePagesRouterWorkerEntry()) was missing several request handling steps that the Node.js production server (prod-server.ts) already handled. This brings the two implementations in sync.

  • Import and call runMiddleware and apply vinextConfig rules (redirects, rewrites, headers) in the generated worker entry
  • Handle basePath stripping, trailing slash normalization, and request context construction in the same order as prod-server
  • Merge middleware/config headers into responses with correct precedence (response headers override middleware headers)
  • Guard renderPage with a typeof check for robustness
  • Export vinext/config/config-matchers from the package so the worker entry can import the shared matching utilities
  • Update both Pages Router examples (pages-router-cloudflare, realworld-api-rest) to match

Test plan

  • 133 deploy tests pass (17 new, covering middleware execution, config application, ordering, header precedence, basePath handling)
  • Typecheck clean (tsgo --noEmit)
  • Lint clean (oxlint --deny-warnings)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/171 **Author:** [@southpolesteve](https://github.com/southpolesteve) **Created:** 2/27/2026 **Status:** ✅ Merged **Merged:** 2/27/2026 **Merged by:** [@southpolesteve](https://github.com/southpolesteve) **Base:** `main` ← **Head:** `fix/pages-router-worker-request-handling` --- ### 📝 Commits (4) - [`d951af6`](https://github.com/cloudflare/vinext/commit/d951af6a9bc4e890d8a74fc668b4d588ba923257) Skip deploy previews for fork PRs that lack Cloudflare secrets - [`fec8d6c`](https://github.com/cloudflare/vinext/commit/fec8d6ce0859ad6397585c919ab2c3f3fa85d14f) fix: align Pages Router worker entry with prod-server request handling - [`7df2f50`](https://github.com/cloudflare/vinext/commit/7df2f502f317ca0f17f01b01e379cda5baba134e) Merge main into fix/pages-router-worker-request-handling - [`28bd1be`](https://github.com/cloudflare/vinext/commit/28bd1beb37275f90df0bd7b72ee7b3d18affdbee) chore: sync pnpm-lock.yaml with upstream package.json changes ### 📊 Changes **7 files changed** (+907 additions, -184 deletions) <details> <summary>View changed files</summary> 📝 `examples/pages-router-cloudflare/worker/index.ts` (+203 -10) 📝 `examples/realworld-api-rest/worker/index.ts` (+203 -10) 📝 `package.json` (+2 -3) 📝 `packages/vinext/package.json` (+4 -0) 📝 `packages/vinext/src/deploy.ts` (+218 -11) 📝 `pnpm-lock.yaml` (+151 -147) 📝 `tests/deploy.test.ts` (+126 -3) </details> ### 📄 Description ## Summary The generated Cloudflare Worker entry for Pages Router apps (`generatePagesRouterWorkerEntry()`) was missing several request handling steps that the Node.js production server (`prod-server.ts`) already handled. This brings the two implementations in sync. - Import and call `runMiddleware` and apply `vinextConfig` rules (redirects, rewrites, headers) in the generated worker entry - Handle basePath stripping, trailing slash normalization, and request context construction in the same order as prod-server - Merge middleware/config headers into responses with correct precedence (response headers override middleware headers) - Guard `renderPage` with a `typeof` check for robustness - Export `vinext/config/config-matchers` from the package so the worker entry can import the shared matching utilities - Update both Pages Router examples (`pages-router-cloudflare`, `realworld-api-rest`) to match ## Test plan - 133 deploy tests pass (17 new, covering middleware execution, config application, ordering, header precedence, basePath handling) - Typecheck clean (`tsgo --noEmit`) - Lint clean (`oxlint --deny-warnings`) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:39:27 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#367
No description provided.