Unverified Commit b1a1c80e authored by lindsaylevine's avatar lindsaylevine Committed by GitHub

bug (#21943): remove incorrect rewrite of parsedUrl.pathname in serverless handler (#22445)

Fixes https://github.com/vercel/next.js/issues/21943

i confirmed in a personal test repo that this solves the issue of infinite 307s on root level non-default locales :)  let me know what else this needs if anything! thanks for the time/help @ijjk ❤️ 
parent 69fe678e
......@@ -333,6 +333,7 @@ export function getUtils({
shouldNotRedirect: boolean
) {
if (!i18n) return
const pathname = parsedUrl.pathname || '/'
let defaultLocale = i18n.defaultLocale
let detectedLocale = detectLocaleCookie(req, i18n.locales)
......@@ -356,10 +357,7 @@ export function getUtils({
detectedLocale = detectedLocale || acceptPreferredLocale
let localeDomainRedirect
const localePathResult = normalizeLocalePath(
parsedUrl.pathname!,
i18n.locales
)
const localePathResult = normalizeLocalePath(pathname, i18n.locales)
routeNoAssetPath = normalizeLocalePath(routeNoAssetPath, i18n.locales)
.pathname
......@@ -395,7 +393,7 @@ export function getUtils({
}
}
const denormalizedPagePath = denormalizePagePath(parsedUrl.pathname || '/')
const denormalizedPagePath = denormalizePagePath(pathname)
const detectedDefaultLocale =
!detectedLocale ||
detectedLocale.toLowerCase() === defaultLocale.toLowerCase()
......
......@@ -315,11 +315,16 @@ describe('i18n Support Root Catch-all', () => {
redirect: 'manual',
})
const res4 = await fetchViaHTTP(port, '/fr', undefined, {
redirect: 'manual',
})
server.close()
expect(res.status).toBe(200)
expect(res2.status).toBe(200)
expect(res3.status).toBe(200)
expect(res4.status).toBe(200)
const $ = cheerio.load(await res.text())
const $2 = cheerio.load(await res2.text())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment