Skip to content

Commit 62fb290

Browse files
committed
chore: migrate from middleware.ts to proxy.ts for Next.js 16 compatibility
Migrate from the deprecated middleware.ts file convention to the new proxy.ts convention as required by Next.js 16.0.10. The middleware file convention has been deprecated and renamed to 'proxy' to better clarify its purpose as a network boundary in front of the app, and to avoid confusion with Express.js middleware. Changes: - Rename apps/site/middleware.ts to apps/site/proxy.ts - Add named export function 'proxy' instead of default export - Add NextRequest type import for type safety - Maintain full compatibility with next-intl internationalization - Update comments to reflect proxy terminology This resolves the deprecation warning: 'The middleware file convention is deprecated. Please use proxy instead.' Refs: https://nextjs.org/docs/messages/middleware-to-proxy
1 parent b5ccb5f commit 62fb290

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import createMiddleware from 'next-intl/middleware';
22

33
import { availableLocaleCodes, defaultLocale } from '#site/next.locales.mjs';
44

5-
export default createMiddleware({
5+
import type { NextRequest } from 'next/server';
6+
7+
// Migrated from middleware.ts to proxy.ts as per Next.js 16 deprecation
8+
// The middleware file convention is deprecated and has been renamed to proxy
9+
// See: https://nextjs.org/docs/messages/middleware-to-proxy
10+
11+
// Create the intl middleware handler
12+
const intlMiddleware = createMiddleware({
613
// A list of all locales that are supported
714
locales: availableLocaleCodes,
815

@@ -17,6 +24,11 @@ export default createMiddleware({
1724
alternateLinks: false,
1825
});
1926

20-
// We only want the middleware to run on the `/` route
27+
// Export as proxy function (required by Next.js 16+)
28+
export function proxy(request: NextRequest) {
29+
return intlMiddleware(request);
30+
}
31+
32+
// We only want the proxy to run on the `/` route
2133
// to redirect users to their preferred locale
2234
export const config = { matcher: ['/'] };

0 commit comments

Comments
 (0)