File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -266,7 +266,9 @@ export default function createMiddleware<
266
266
} else {
267
267
const internalHref = formatPathname (
268
268
unprefixedInternalPathname ,
269
- getLocaleAsPrefix ( locale ) ,
269
+ resolvedRouting . optimalRouting
270
+ ? undefined
271
+ : getLocaleAsPrefix ( locale ) ,
270
272
request . nextUrl . search
271
273
) ;
272
274
@@ -318,6 +320,7 @@ export default function createMiddleware<
318
320
if ( isUnprefixedRouting ) {
319
321
response = rewrite ( internalHref ) ;
320
322
} else {
323
+ console . log ( 'formatPathname 8' , getLocalePrefix ( locale , resolvedRouting . localePrefix ) ) ;
321
324
response = redirect (
322
325
formatPathname (
323
326
unprefixedExternalPathname ,
Original file line number Diff line number Diff line change @@ -66,6 +66,12 @@ export type RoutingConfig<
66
66
**/
67
67
alternateLinks ?: boolean ;
68
68
69
+ /**
70
+ * Allows having the optimal routing for the current request by bypassing middleware
71
+ * and using the default locale when no locale is presented via the URL or domains.
72
+ **/
73
+ optimalRouting ?: boolean ;
74
+
69
75
/**
70
76
* By setting this to `false`, the cookie as well as the `accept-language` header will no longer be used for locale detection.
71
77
* @see https://next-intl.dev/docs/routing/middleware#locale-detection
You can’t perform that action at this time.
0 commit comments