Files
breakpilot-lehrer/studio-v2/app/api/user/[...path]/route.ts
Benjamin Admin d4959172a9 Add migration learning platform: Onboarding, Translation, Parent Portal
Phase 1.1 — user_language_api.py: Stores native language preference
per user (TR/AR/UK/RU/PL/DE/EN). Onboarding page with flag-based
language selection for students and parents.

Phase 1.2 — translation_service.py: Batch-translates vocabulary words
into target languages via Ollama LLM. Stores in translations JSONB.
New endpoint POST /vocabulary/translate triggers translation.

Phase 2.1 — Parent Portal (/parent): Simplified UI in parent's native
language showing child's learning progress. Daily tips translated.

Phase 2.2 — Parent Quiz (/parent/quiz/[unitId]): Parents can quiz
their child on vocabulary WITHOUT speaking DE or EN. Shows word in
child's learning language + parent's native language as hint.
Answer hidden by default, revealed on tap.

All UI text translated into 7 languages (DE/EN/TR/AR/UK/RU/PL).
Arabic gets RTL layout support.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-25 20:17:25 +02:00

36 lines
1.2 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server'
const BACKEND_URL = process.env.BACKEND_URL || 'http://backend-lehrer:8001'
async function proxyRequest(
request: NextRequest,
{ params }: { params: Promise<{ path: string[] }> }
): Promise<NextResponse> {
const { path } = await params
const pathStr = path.join('/')
const searchParams = request.nextUrl.searchParams.toString()
const url = `${BACKEND_URL}/api/user/${pathStr}${searchParams ? `?${searchParams}` : ''}`
try {
const fetchOptions: RequestInit = {
method: request.method,
headers: { 'Content-Type': 'application/json' },
}
if (request.method !== 'GET' && request.method !== 'HEAD') {
fetchOptions.body = await request.text()
}
const resp = await fetch(url, fetchOptions)
const data = await resp.text()
return new NextResponse(data, {
status: resp.status,
headers: { 'Content-Type': resp.headers.get('Content-Type') || 'application/json' },
})
} catch (e) {
return NextResponse.json({ error: String(e) }, { status: 502 })
}
}
export const GET = proxyRequest
export const POST = proxyRequest
export const PUT = proxyRequest