@@ -20,7 +20,7 @@ export interface FetchEventResult {
20
20
21
21
interface BuildResponseOptions {
22
22
context : Context
23
- config ?: NetlifyNextRequest [ 'nextConfig' ]
23
+ nextConfig ?: NetlifyNextRequest [ 'nextConfig' ]
24
24
locale ?: string
25
25
request : Request
26
26
result : FetchEventResult
@@ -29,7 +29,7 @@ interface BuildResponseOptions {
29
29
30
30
export const buildResponse = async ( {
31
31
context,
32
- config ,
32
+ nextConfig ,
33
33
locale,
34
34
request,
35
35
result,
@@ -185,9 +185,9 @@ export const buildResponse = async ({
185
185
}
186
186
187
187
// respect trailing slash rules to prevent 308s
188
- rewriteUrl . pathname = normalizeTrailingSlash ( rewriteUrl . pathname , config ?. trailingSlash )
188
+ rewriteUrl . pathname = normalizeTrailingSlash ( rewriteUrl . pathname , nextConfig ?. trailingSlash )
189
189
190
- const target = normalizeLocalizedTarget ( { target : rewriteUrl . toString ( ) , request, config } )
190
+ const target = normalizeLocalizedTarget ( { target : rewriteUrl . toString ( ) , request, nextConfig } )
191
191
if ( target === request . url ) {
192
192
logger . withFields ( { rewrite_url : rewrite } ) . debug ( 'Rewrite url is same as original url' )
193
193
return
@@ -199,7 +199,7 @@ export const buildResponse = async ({
199
199
200
200
// If we are redirecting a request that had a locale in the URL, we need to add it back in
201
201
if ( redirect && locale ) {
202
- redirect = normalizeLocalizedTarget ( { target : redirect , request, config } )
202
+ redirect = normalizeLocalizedTarget ( { target : redirect , request, nextConfig } )
203
203
if ( redirect === request . url ) {
204
204
logger . withFields ( { rewrite_url : rewrite } ) . debug ( 'Rewrite url is same as original url' )
205
205
return
@@ -233,16 +233,16 @@ export const buildResponse = async ({
233
233
function normalizeLocalizedTarget ( {
234
234
target,
235
235
request,
236
- config ,
236
+ nextConfig ,
237
237
locale,
238
238
} : {
239
239
target : string
240
240
request : Request
241
- config ?: NetlifyNextRequest [ 'nextConfig' ]
241
+ nextConfig ?: NetlifyNextRequest [ 'nextConfig' ]
242
242
locale ?: string
243
243
} ) {
244
244
const targetUrl = new URL ( target , request . url )
245
- const normalizedTarget = normalizeLocalePath ( targetUrl . pathname , config ?. i18n ?. locales )
245
+ const normalizedTarget = normalizeLocalePath ( targetUrl . pathname , nextConfig ?. i18n ?. locales )
246
246
const targetPathname = normalizedTarget . pathname
247
247
const targetLocale = normalizedTarget . detectedLocale ?? locale
248
248
@@ -251,9 +251,10 @@ function normalizeLocalizedTarget({
251
251
! targetPathname . startsWith ( `/api/` ) &&
252
252
! targetPathname . startsWith ( `/_next/static/` )
253
253
) {
254
- targetUrl . pathname = addBasePath ( `/${ targetLocale } ${ targetPathname } ` , config ?. basePath ) || `/`
254
+ targetUrl . pathname =
255
+ addBasePath ( `/${ targetLocale } ${ targetPathname } ` , nextConfig ?. basePath ) || `/`
255
256
} else {
256
- targetUrl . pathname = addBasePath ( targetPathname , config ?. basePath ) || `/`
257
+ targetUrl . pathname = addBasePath ( targetPathname , nextConfig ?. basePath ) || `/`
257
258
}
258
259
return targetUrl . toString ( )
259
260
}
0 commit comments