Skip to content

chore(open-next): use proxy.ts instead of middleware.ts - #9215

Draft
ovflowd wants to merge 1 commit into
mainfrom
feat/next-proxy
Draft

ovflowd wants to merge 1 commit into
mainfrom
feat/next-proxy

Conversation

@ovflowd

@ovflowd ovflowd commented Oct 11, 2026

Copy link
Copy Markdown
Member

Description

This PR renames apps/site/middleware.ts to apps/site/proxy.ts, following the Next.js 16 proxy.ts file convention.

We stuck with middleware.ts because proxy.ts always runs on the Node.js runtime, and OpenNext's Cloudflare adapter only supported Edge middleware. That changed in @opennextjs/cloudflare@1.20.3 (opennextjs/opennextjs-cloudflare#1309), so this also bumps it from ^1.20.2 to ^1.20.10. The same release has opennextjs/opennextjs-cloudflare#1359, which we need too since we register an instrumentation hook: without it every request going through a Node.js middleware fails on workerd with Dynamic require of ".next/server/instrumentation.js" is not supported.

The proxy's code itself doesn't change. next-intl has no next-intl/proxy entry point (not even on the latest 4.14.9), so createMiddleware from next-intl/middleware is still the API to use. Besides that:

  • Updated the path in CODEOWNERS
  • Fixed a stale next.middleware.js reference in docs/technologies.md

The extra churn in pnpm-lock.yaml is OpenNext's own dependency tree (@opennextjs/aws 4.1.0 → 4.1.9).

Note

OpenNext warns during the build that Node.js middleware support on Cloudflare is experimental and not officially maintained by the OpenNext maintainers. Our proxy only runs on / to redirect to the preferred locale, so the blast radius is small, but it's something to keep an eye on.

Validation

  • turbo build --filter=@node-core/platform-cloudflare passes: Next.js lists ƒ Proxy (Middleware) and OpenNext bundles it as a Node.js middleware.
  • Ran the built worker with wrangler dev and requested / with different Accept-Language headers: fr → 307 /fr, es → 307 /es, de (disabled locale) and no header → 307 /en. /en and /fr/about return 200, and there are no errors in the worker logs.
  • pnpm test, ESLint, Prettier and tsc pass locally, and changeset status is clean since both touched packages are private.

Vercel supports proxy.ts natively on Next.js 16, so the Vercel preview on this PR should confirm that side. Static export builds aren't affected, Next.js treats proxy.ts there the same way it treated middleware.ts.

Related Issues

N/A

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run pnpm format to ensure the code follows the style guide.
  • I have run pnpm test to check if all tests are passing.
  • I have run pnpm build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

Next.js 16 deprecated the `middleware.ts` convention in favour of
`proxy.ts`. We kept the old one because OpenNext's Cloudflare adapter
only supported Edge middleware, and `proxy.ts` always runs on the
Node.js runtime. `@opennextjs/cloudflare@1.20.3` added support for
Node.js middleware, so this bumps it to the latest release and renames
the file.

next-intl has no `proxy` entry point; `createMiddleware` from
`next-intl/middleware` is still the API to use, so the code itself
doesn't change.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
@ovflowd
ovflowd requested review from a team as code owners October 11, 2026 12:57
Copilot AI balanced review requested due to automatic review settings October 11, 2026 12:57
@vercel

vercel Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nodejs-org Ready Ready Preview Oct 11, 2026 12:58pm UTC

Request Review

@codecov

codecov Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.02%. Comparing base (922aae3) to head (2da1a1c).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9215      +/-   ##
==========================================
- Coverage   86.04%   86.02%   -0.02%     
==========================================
  Files          86       86              
  Lines        6075     6075              
  Branches      361      361              
==========================================
- Hits         5227     5226       -1     
- Misses        844      845       +1     
  Partials        4        4              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The updated adapter’s required Next.js and Wrangler peer versions are not satisfied.

1 open finding
What changed in this PR

Renames the locale middleware to Next.js 16’s proxy.ts convention and updates Cloudflare support.

Changes:

  • Renames middleware references to proxy.
  • Updates OpenNext Cloudflare and transitive dependencies.
  • Updates ownership and documentation references.
File Description
apps/​site/​proxy.ts Updates proxy terminology.
platforms/​cloudflare/​package.json Bumps OpenNext Cloudflare.
pnpm-lock.yaml Updates resolved dependencies.
.github/​CODEOWNERS Updates the owned proxy path.
docs/​technologies.md Corrects the locale-routing filename.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

"dependencies": {
"@flarelabs-net/wrangler-build-time-fs-assets-polyfilling": "^0.0.1",
"@opennextjs/cloudflare": "^1.20.2",
"@opennextjs/cloudflare": "^1.20.10",
@github-actions

Copy link
Copy Markdown
Contributor

📦 Build Size Comparison

Summary

Metric Value
Old Total First Load JS 7.20 MB
New Total First Load JS 7.20 MB
Delta 0 B (0.00%)

@ovflowd
ovflowd marked this pull request as draft October 11, 2026 13:19

This branch was successfully deployed

1 active deployment
Preview — 2da1a1ce Deployed Oct 11, 2026 by vercel[bot]
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.

2 participants