@@ -24,6 +24,7 @@ export interface RequestData {
24
24
basePath ?: string
25
25
i18n ?: I18NConfig | null
26
26
trailingSlash ?: boolean
27
+ skipMiddlewareUrlNormalize ?: boolean
27
28
}
28
29
page ?: {
29
30
name ?: string
@@ -50,19 +51,23 @@ const normalizeRequestURL = (
50
51
url . pathname ,
51
52
nextConfig ?. i18n ?. locales ,
52
53
)
53
- url . pathname = pathname
54
+ if ( ! nextConfig ?. skipMiddlewareUrlNormalize ) {
55
+ url . pathname = pathname || '/'
56
+ }
54
57
detectedLocale = detected
55
58
}
56
59
57
- // We want to run middleware for data requests and expose the URL of the
58
- // corresponding pages, so we have to normalize the URLs before running
59
- // the handler.
60
- url . pathname = normalizeDataUrl ( url . pathname )
60
+ if ( ! nextConfig ?. skipMiddlewareUrlNormalize ) {
61
+ // We want to run middleware for data requests and expose the URL of the
62
+ // corresponding pages, so we have to normalize the URLs before running
63
+ // the handler.
64
+ url . pathname = normalizeDataUrl ( url . pathname )
61
65
62
- // Normalizing the trailing slash based on the `trailingSlash` configuration
63
- // property from the Next.js config.
64
- if ( nextConfig ?. trailingSlash && url . pathname !== '/' && ! url . pathname . endsWith ( '/' ) ) {
65
- url . pathname = `${ url . pathname } /`
66
+ // Normalizing the trailing slash based on the `trailingSlash` configuration
67
+ // property from the Next.js config.
68
+ if ( nextConfig ?. trailingSlash && url . pathname !== '/' && ! url . pathname . endsWith ( '/' ) ) {
69
+ url . pathname = `${ url . pathname } /`
70
+ }
66
71
}
67
72
68
73
if ( didRemoveBasePath ) {
0 commit comments