|
1 | | -import type { NextRequest } from 'next/server' |
2 | 1 | import createMiddleware from 'next-intl/middleware' |
3 | | -import { defaultLocale, locales } from './i18n/config' |
| 2 | +import { routing } from './i18n/routing' |
4 | 3 |
|
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) |
30 | 8 |
|
31 | 9 | export const config = { |
32 | 10 | // Match only internationalized pathnames |
|
0 commit comments