diff --git a/server/index.ts b/server/index.ts index 9b91c3e..32deafa 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1902,7 +1902,7 @@ app.post("/api/ascii-gen", async (c) => { prompt, width: width || 80, height: height || 40, - palette: palette || "ansi", + palette: palette || "classic", output_format: output_format || "html", }), signal: AbortSignal.timeout(30_000), @@ -1911,8 +1911,11 @@ app.post("/api/ascii-gen", async (c) => { const err = await res.text(); return c.json({ error: `ASCII art service error: ${err}` }, res.status as any); } - const data = await res.json(); - return c.json(data); + // Service returns raw HTML — wrap in JSON for the client + const htmlContent = await res.text(); + // Strip HTML tags to get plain text version + const textContent = htmlContent.replace(/<[^>]*>/g, "").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&"); + return c.json({ html: htmlContent, text: textContent }); } catch (e: any) { console.error("[ascii-gen] error:", e); return c.json({ error: `ASCII art service unavailable: ${e.message}` }, 502); @@ -1931,8 +1934,9 @@ app.post("/api/ascii-gen/render", async (c) => { const err = await res.text(); return c.json({ error: `ASCII render error: ${err}` }, res.status as any); } - const data = await res.json(); - return c.json(data); + const htmlContent = await res.text(); + const textContent = htmlContent.replace(/<[^>]*>/g, "").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&"); + return c.json({ html: htmlContent, text: textContent }); } catch (e: any) { console.error("[ascii-gen] render error:", e); return c.json({ error: `ASCII art service unavailable: ${e.message}` }, 502);