From 705fd5ac6fa5d2fcc6450bd4e986d31dcc81cda6 Mon Sep 17 00:00:00 2001 From: hex2077 Date: Tue, 26 Aug 2025 22:09:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(api):=20=E4=BF=AE=E5=A4=8D=E6=96=B0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=B7=AF=E7=94=B1=E4=B8=AD=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原逻辑从请求头获取语言参数可能导致错误,改为优先从pathname获取。当pathname不存在时使用默认语言,确保翻译功能正常工作 --- web/src/app/api/newuser/route.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/web/src/app/api/newuser/route.ts b/web/src/app/api/newuser/route.ts index 83e4d7b..2066a3c 100644 --- a/web/src/app/api/newuser/route.ts +++ b/web/src/app/api/newuser/route.ts @@ -5,9 +5,6 @@ import { getTranslation } from '@/i18n'; import { fallbackLng } from '@/i18n/settings'; export async function GET(request: NextRequest) { - const lng = request.headers.get('x-next-pathname') || fallbackLng; - const { t } = await getTranslation(lng, 'components'); - const sessionData = await getSessionData(); let baseUrl = process.env.NEXT_PUBLIC_BASE_URL || "/"; const pathname = request.nextUrl.searchParams.get('pathname'); @@ -21,7 +18,8 @@ export async function GET(request: NextRequest) { return NextResponse.redirect(url); } - + const lng = !pathname ? fallbackLng : pathname.replace('/',''); + const { t } = await getTranslation(lng, 'components'); const userId = sessionData.user.id; // 获取 userId // 检查用户是否已存在积分账户