import { NextResponse } from 'next/server'; const TTS_API = "http://185.45.195.201:5001/api/tts/base64"; export async function POST(request: Request) { try { const { text, lang = "es" } = await request.json(); if (!text) { return NextResponse.json({ error: "No text provided" }, { status: 400 }); } // Call Cleopatra's TTS API (HTTP) const response = await fetch(TTS_API, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text, lang }) }); if (!response.ok) { throw new Error("TTS API error"); } const data = await response.json(); return NextResponse.json(data); } catch (error) { console.error("TTS proxy error:", error); return NextResponse.json({ error: "TTS failed" }, { status: 500 }); } }