Skip to content

Commit

Permalink
Ensure locale redirects are not applied in minimal mode (#39436)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Aug 9, 2022
1 parent ed14af3 commit 997e3c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/server/base-server.ts
Expand Up @@ -617,7 +617,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
}
}

if (defaultLocale) {
if (!this.minimalMode && defaultLocale) {
const redirect = getLocaleRedirect({
defaultLocale,
domainLocale,
Expand Down
21 changes: 21 additions & 0 deletions test/production/required-server-files-i18n.test.ts
Expand Up @@ -135,6 +135,27 @@ describe('should set-up next', () => {
if (server) await killApp(server)
})

it('should not apply locale redirect in minimal mode', async () => {
const res = await fetchViaHTTP(appPort, '/', undefined, {
redirect: 'manual',
headers: {
'accept-language': 'fr',
},
})
expect(res.status).toBe(200)
expect(await res.text()).toContain('index page')

const resCookie = await fetchViaHTTP(appPort, '/', undefined, {
redirect: 'manual',
headers: {
'accept-language': 'en',
cookie: 'NEXT_LOCALE=fr',
},
})
expect(resCookie.status).toBe(200)
expect(await resCookie.text()).toContain('index page')
})

it('should output required-server-files manifest correctly', async () => {
expect(requiredFilesManifest.version).toBe(1)
expect(Array.isArray(requiredFilesManifest.files)).toBe(true)
Expand Down

0 comments on commit 997e3c0

Please sign in to comment.