diff --git a/memento-note/lib/ai/tools/pptx.tool.ts b/memento-note/lib/ai/tools/pptx.tool.ts index 7609786..32309e1 100644 --- a/memento-note/lib/ai/tools/pptx.tool.ts +++ b/memento-note/lib/ai/tools/pptx.tool.ts @@ -1111,6 +1111,26 @@ RULES: if (spec.slides.length === 0) return { success: false, error: 'No slides provided' } + // Pre-fetch all image URLs server-side and convert to base64 data URIs. + // pptxgenjs on Node.js cannot reliably fetch authenticated or relative URLs, + // so we do it here where we have full server context. + for (const slide of spec.slides) { + if (!slide.imageUrl || slide.imageUrl.startsWith('data:')) continue + try { + const res = await fetch(slide.imageUrl, { signal: AbortSignal.timeout(8000) }) + if (res.ok) { + const buf = await res.arrayBuffer() + const mime = res.headers.get('content-type') || 'image/png' + const b64 = Buffer.from(buf).toString('base64') + slide.imageUrl = `data:${mime};base64,${b64}` + } else { + slide.imageUrl = undefined // failed: show placeholder text + } + } catch { + slide.imageUrl = undefined + } + } + const pptx = buildPresentation(spec) const base64 = await pptx.write({ outputType: 'base64' }) as string