diff --git a/lib/og-helper.tsx b/lib/og-helper.tsx index 27101c5b..4f36be5e 100644 --- a/lib/og-helper.tsx +++ b/lib/og-helper.tsx @@ -11,10 +11,21 @@ export async function getOgFonts() { try { console.log(`[OG] Loading fonts: bold=${boldFontPath}, regular=${regularFontPath}`); - const boldFont = readFileSync(boldFontPath); - const regularFont = readFileSync(regularFontPath); + const boldFontBuffer = readFileSync(boldFontPath); + const regularFontBuffer = readFileSync(regularFontPath); + + // Satori (Vercel OG) strictly requires an ArrayBuffer, not a Node Buffer view. + const boldFont = boldFontBuffer.buffer.slice( + boldFontBuffer.byteOffset, + boldFontBuffer.byteOffset + boldFontBuffer.byteLength, + ); + const regularFont = regularFontBuffer.buffer.slice( + regularFontBuffer.byteOffset, + regularFontBuffer.byteOffset + regularFontBuffer.byteLength, + ); + console.log( - `[OG] Fonts loaded successfully (${boldFont.length} and ${regularFont.length} bytes)`, + `[OG] Fonts loaded successfully (${boldFont.byteLength} and ${regularFont.byteLength} bytes)`, ); return [