Skip to content

Commit 9936900

Browse files
feat(middleware): Update domain-based language redirect logic
1 parent da18ff4 commit 9936900

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

middleware.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import { NextFetchEvent, NextRequest, NextResponse } from 'next/server';
55
export async function middleware(request: NextRequest, event: NextFetchEvent) {
66
const { pathname } = request.nextUrl;
77

8-
if (pathname.startsWith('/zh-cn') && i18n.defaultLanguage === 'en') {
9-
return NextResponse.redirect(`https://sealos.run/docs/5.0.0/Intro`);
8+
if (request.nextUrl.hostname === 'sealos.io' && pathname.startsWith('/zh-cn')) {
9+
return NextResponse.redirect(new URL(`https://sealos.run${pathname}`));
1010
}
11-
12-
if (pathname.startsWith('/en') && i18n.defaultLanguage === 'zh-cn') {
13-
return NextResponse.redirect(`https://sealos.io${pathname}`);
11+
if (request.nextUrl.hostname === 'sealos.run' && pathname.startsWith('/en')) {
12+
return NextResponse.redirect(new URL(`https://sealos.io${pathname}`));
1413
}
1514

1615
if (pathname === '/robots.txt') {

0 commit comments

Comments
 (0)