File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import type { NextRequest } from 'next/server'
21import createMiddleware from 'next-intl/middleware'
3- import { defaultLocale , locales } from './i18n/config '
2+ import { routing } from './i18n/routing '
43
5- const intlMiddleware = createMiddleware ( {
6- // A list of all locales that are supported
7- locales,
8-
9- // Used when no locale matches
10- defaultLocale,
11-
12- // Don't prefix the default locale (English)
13- localePrefix : 'as-needed' ,
14-
15- // Detect locale from Accept-Language header
16- localeDetection : true ,
17- } )
18-
19- export default function middleware ( request : NextRequest ) {
20- // Check for stored locale preference
21- const localeCookie = request . cookies . get ( 'NEXT_LOCALE' )
22- if ( localeCookie ?. value ) {
23- // Clone the request headers and add the locale preference
24- const requestHeaders = new Headers ( request . headers )
25- requestHeaders . set ( 'x-locale-preference' , localeCookie . value )
26- }
27-
28- return intlMiddleware ( request )
29- }
4+ // Next.js 16 Proxy always uses the Node.js runtime, which the current
5+ // @opennextjs /cloudflare adapter does not support for middleware yet.
6+ // Keep the legacy Edge Middleware convention until adapter support lands.
7+ export default createMiddleware ( routing )
308
319export const config = {
3210 // Match only internationalized pathnames
You can’t perform that action at this time.
0 commit comments