fix(api): 修复新用户路由中语言参数获取逻辑
原逻辑从请求头获取语言参数可能导致错误,改为优先从pathname获取。当pathname不存在时使用默认语言,确保翻译功能正常工作
This commit is contained in:
@@ -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
|
||||
|
||||
// 检查用户是否已存在积分账户
|
||||
|
||||
Reference in New Issue
Block a user