Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure locale redirects are not applied in minimal mode #39436

Merged
merged 1 commit into from Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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