migrating-middleware-to-proxy

Migrate Next.js 16 middleware.ts to proxy.ts with renamed exports and relocated auth logic.

Updated Nov 21, 2025
One-click install
npx skills add https://github.com/djankies/claude-configs --skill migrating-middleware-to-proxy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrating-middleware-to-proxy
Source: https://github.com/djankies/claude-configs/tree/main/prisma-6/skills/migrating-middleware-to-proxy
Command: npx skills add https://github.com/djankies/claude-configs --skill migrating-middleware-to-proxy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Next.js 16 renames middleware.ts to proxy.ts and the middleware export to proxy. This breaking change has security implications. The skill guides a safe migration and clarifies the new proxy-based pattern.

Core Features & Use Cases

  • Rename file to proxy.ts and export to proxy to align with Next.js 16.
  • Move authentication-focused logic out of middleware to server components/route handlers.
  • Understand what proxy.ts should be used for (headers, logging, URL rewriting) vs what it should not handle (authentication).

Quick Start

Rename middleware.ts to proxy.ts, rename exports to proxy, update configuration if needed, and relocate auth logic to server components/route handlers.

Frequently Asked Questions about migrating-middleware-to-proxy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate middleware.ts to proxy.ts in Next.js 16?

Migrating middleware.ts to proxy.ts in Next.js 16 requires renaming the file, changing the middleware export to proxy, keeping NextResponse and matcher config identical, and moving authentication logic to server components or route handlers instead.

Why does Next.js 16 rename middleware to proxy?

Next.js 16 renames middleware.ts to proxy.ts and the middleware export to proxy to align the API with its new proxy-based pattern and address security implications of the previous middleware architecture.

What should proxy.ts handle versus what belongs in server components?

Proxy.ts handles headers, logging, and URL rewriting. Authentication logic must move to server components or route handlers; keeping auth out of proxy.ts enforces the separation between request routing and identity verification.

Do I need to update my matcher configuration when migrating to proxy.ts?

No, matcher configuration remains identical during migration from middleware.ts to proxy.ts; only the file name, export name, and auth delegation change.

Can I keep authentication in proxy.ts after migrating from middleware.ts?

No, authentication logic must be excluded from proxy.ts and delegated to server components or route handlers. Proxy.ts is designed for request interception tasks like headers and rewriting, not identity verification.

What breaking changes does Next.js 16 middleware migration address?

Next.js 16 middleware migration addresses the CVE-2025-29927 breaking change by enforcing separation of concerns: proxy.ts handles routing concerns while server components and route handlers handle authentication, eliminating security vulnerabilities from mixed responsibilities.