Skip to content

refactor(core): migrate middleware to proxy pattern#2912

Merged
matthewvolk merged 1 commit intocanaryfrom
CATALYST-1792-proxy-ts
Mar 10, 2026
Merged

refactor(core): migrate middleware to proxy pattern#2912
matthewvolk merged 1 commit intocanaryfrom
CATALYST-1792-proxy-ts

Conversation

@matthewvolk
Copy link
Contributor

@matthewvolk matthewvolk commented Mar 9, 2026

Warning

This PR is dependent on #2907. That PR must be merged first. DONE ✅

What/Why?

Next.js 16 deprecates middleware.ts in favor of proxy.ts to clarify its network-boundary purpose. This PR migrates Catalyst to the new proxy pattern and enforces the Node 24 runtime requirement.

  • Renames middleware.tsproxy.ts and export const middlewareexport const proxy
  • Adds engines field to package.json enforcing Node.js ≥24 (proxy runs on Node.js runtime, not Edge)
  • Updates AGENTS.md architecture docs to reflect proxy terminology
  • Appends proxy migration instructions to the existing Next.js 16 changeset

Internal middleware composition (middlewares/ directory, MiddlewareFactory type, composeMiddlewares, all with-*.ts files) is unchanged — these are implementation details, not Next.js conventions.

Testing

  • Run pnpm run build in core/ and verify build completes
  • Run pnpm run dev in core/ and verify pages render
  • Confirm auth redirects work (visit /account while logged out → redirects to /login)
  • Confirm locale switching works
  • Confirm analytics cookies are set on first visit
  • Run E2E tests: core/tests/ui/e2e/middleware/redirects.spec.ts

Migration

  • Rename middleware.ts to proxy.ts in the root of your Next.js app
  • Change export const middleware to export const proxy
  • Ensure you are running Node.js 24+

@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

⚠️ No Changeset found

Latest commit: 887140c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core Minor

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Mar 9, 2026

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

Project Deployment Actions Updated (UTC)
catalyst Ready Ready Preview, Comment Mar 10, 2026 5:02pm

Request Review

Copy link
Contributor

@chanceaclark chanceaclark left a comment

Choose a reason for hiding this comment

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

LGTM. Let's check to see if we need to update any public documentation too.

Next.js 16 deprecates middleware.ts in favor of proxy.ts. This renames
the entry point, export, composition utilities, and directory to align
with the new convention.

Also enforces Node 24 via engines field in package.json, since proxy
runs on the Node.js runtime (not Edge).
@github-actions
Copy link
Contributor

Bundle Size Report

Comparing against baseline from e3185b6 (2026-03-10).

No bundle size changes detected.

@matthewvolk matthewvolk added this pull request to the merge queue Mar 10, 2026
Merged via the queue into canary with commit a00e474 Mar 10, 2026
13 of 17 checks passed
@matthewvolk matthewvolk deleted the CATALYST-1792-proxy-ts branch March 10, 2026 17:13
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.

3 participants