Skip to content

Commit a14f68f

Browse files
Merge branch 'main' into docs/refactor-playground
2 parents 7602243 + 940dfbf commit a14f68f

12 files changed

Lines changed: 47 additions & 49 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## 4.11.2 (2026-05-11)
7+
8+
### Bug Fixes
9+
10+
* Revert x-forwarded-host redirect domain change ([#2322](https://github.com/amannn/next-intl/issues/2322)) ([eb3a6a4](https://github.com/amannn/next-intl/commit/eb3a6a4eb26a6e0c02a297efbe1b139983faae4e)) – by @amannn
11+
612
## 4.11.1 (2026-05-08)
713

814
### Bug Fixes

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "node_modules/@lerna-lite/cli/schemas/lerna-schema.json",
3-
"version": "4.11.1",
3+
"version": "4.11.2",
44
"packages": [
55
"packages/*"
66
],

packages/icu-minify/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## 4.11.2 (2026-05-11)
7+
8+
### Bug Fixes
9+
10+
* Revert x-forwarded-host redirect domain change ([#2322](https://github.com/amannn/next-intl/issues/2322)) ([eb3a6a4](https://github.com/amannn/next-intl/commit/eb3a6a4eb26a6e0c02a297efbe1b139983faae4e)) – by @amannn
11+
612
## 4.11.1 (2026-05-08)
713

814
### Bug Fixes

packages/icu-minify/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "icu-minify",
3-
"version": "4.11.1",
3+
"version": "4.11.2",
44
"sideEffects": false,
55
"author": "Jan Amann <jan@amann.work>",
66
"funding": [

packages/next-intl/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## 4.11.2 (2026-05-11)
7+
8+
### Bug Fixes
9+
10+
* Revert x-forwarded-host redirect domain change ([#2322](https://github.com/amannn/next-intl/issues/2322)) ([eb3a6a4](https://github.com/amannn/next-intl/commit/eb3a6a4eb26a6e0c02a297efbe1b139983faae4e)) – by @amannn
11+
612
## 4.11.1 (2026-05-08)
713

814
### Bug Fixes

packages/next-intl/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "next-intl",
3-
"version": "4.11.1",
3+
"version": "4.11.2",
44
"sideEffects": false,
55
"author": "Jan Amann <jan@amann.work>",
66
"funding": [

packages/next-intl/src/middleware/middleware.test.tsx

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,33 +1172,6 @@ describe('prefix-based routing', () => {
11721172
);
11731173
});
11741174

1175-
it('uses the forwarded host when behind a proxy', () => {
1176-
middleware(
1177-
createMockRequest('/', 'en', 'http://project.vercel.app', undefined, {
1178-
'x-forwarded-host': 'myproject.com',
1179-
'x-forwarded-proto': 'https'
1180-
})
1181-
);
1182-
expect(MockedNextResponse.next).not.toHaveBeenCalled();
1183-
expect(MockedNextResponse.rewrite).not.toHaveBeenCalled();
1184-
expect(MockedNextResponse.redirect.mock.calls[0][0].toString()).toBe(
1185-
'https://myproject.com/en'
1186-
);
1187-
1188-
middleware(
1189-
createMockRequest('/', 'en', 'http://project.vercel.app', undefined, {
1190-
'x-forwarded-host': 'myproject.com',
1191-
'x-forwarded-port': '8443',
1192-
'x-forwarded-proto': 'https'
1193-
})
1194-
);
1195-
expect(MockedNextResponse.next).not.toHaveBeenCalled();
1196-
expect(MockedNextResponse.rewrite).not.toHaveBeenCalled();
1197-
expect(MockedNextResponse.redirect.mock.calls[1][0].toString()).toBe(
1198-
'https://myproject.com:8443/en'
1199-
);
1200-
});
1201-
12021175
it('redirects when a pathname starts with the locale characters', () => {
12031176
middleware(createMockRequest('/engage'));
12041177
expect(MockedNextResponse.rewrite).not.toHaveBeenCalled();

packages/next-intl/src/middleware/middleware.tsx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ export default function createMiddleware<
101101

102102
function redirect(url: string, redirectDomain?: string) {
103103
const urlObj = new URL(url, request.url);
104-
const forwardedHost = request.headers.get('x-forwarded-host');
105104

106105
urlObj.pathname = normalizeTrailingSlash(urlObj.pathname);
107106

@@ -129,24 +128,20 @@ export default function createMiddleware<
129128
}
130129
}
131130

132-
// Priority for redirect origins:
133-
// 1) Explicit domain from `redirectDomain`
134-
// 2) Reverse proxy host from `x-forwarded-host`
135-
// 3) Fallback to `request.url`
136-
const redirectHost = redirectDomain ?? forwardedHost;
137-
if (redirectHost) {
138-
urlObj.host = redirectHost;
139-
}
131+
if (redirectDomain) {
132+
urlObj.host = redirectDomain;
140133

141-
if (forwardedHost) {
142-
urlObj.protocol =
143-
request.headers.get('x-forwarded-proto') ?? request.nextUrl.protocol;
134+
if (request.headers.get('x-forwarded-host')) {
135+
urlObj.protocol =
136+
request.headers.get('x-forwarded-proto') ??
137+
request.nextUrl.protocol;
144138

145-
const redirectHostPort = redirectHost?.split(':')[1] as
146-
| string
147-
| undefined;
148-
urlObj.port =
149-
redirectHostPort ?? request.headers.get('x-forwarded-port') ?? '';
139+
const redirectDomainPort = redirectDomain.split(':')[1] as
140+
| string
141+
| undefined;
142+
urlObj.port =
143+
redirectDomainPort ?? request.headers.get('x-forwarded-port') ?? '';
144+
}
150145
}
151146

152147
if (request.nextUrl.basePath) {

packages/swc-plugin-extractor/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## 4.11.2 (2026-05-11)
7+
8+
### Bug Fixes
9+
10+
* Revert x-forwarded-host redirect domain change ([#2322](https://github.com/amannn/next-intl/issues/2322)) ([eb3a6a4](https://github.com/amannn/next-intl/commit/eb3a6a4eb26a6e0c02a297efbe1b139983faae4e)) – by @amannn
11+
612
## 4.11.1 (2026-05-08)
713

814
### Bug Fixes

packages/swc-plugin-extractor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "next-intl-swc-plugin-extractor",
3-
"version": "4.11.1",
3+
"version": "4.11.2",
44
"sideEffects": false,
55
"author": "강동윤 <kdy1997.dev@gmail.com>",
66
"contributors": [

0 commit comments

Comments
 (0)