From a0491e4755f86ade362a2a0249152d8246bfaa31 Mon Sep 17 00:00:00 2001 From: Harshit Singh <73997189+harshit078@users.noreply.github.com> Date: Tue, 30 Dec 2025 15:59:30 +0530 Subject: [PATCH] fix: images are not included in PDF exports (#16076) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description - This PR address issue https://github.com/twentyhq/twenty/issues/15998 - The issue was that images are stored as signed urls and the backend signed these with JWT - BlockNote `resolveFileUrl` uses a public CORS proxy that couldn’t access authenticated/signed URLs ## Visual Appearance https://github.com/user-attachments/assets/12936451-d91d-4371-bcf7-8a2c2bb68e9c --- .../utils/exportBlockNoteEditorToPdf.ts | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/utils/exportBlockNoteEditorToPdf.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/utils/exportBlockNoteEditorToPdf.ts index 9f3bf0cee4..7841ae878d 100644 --- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/utils/exportBlockNoteEditorToPdf.ts +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/utils/exportBlockNoteEditorToPdf.ts @@ -45,7 +45,34 @@ export const exportBlockNoteEditorToPdf = async ( initialContent: parsedBody, }); - const exporter = new PDFExporter(editor.schema, pdfDefaultSchemaMappings); + const exporter = new PDFExporter(editor.schema, pdfDefaultSchemaMappings, { + resolveFileUrl: async (url: string) => { + try { + const response = await fetch(url, { + mode: 'cors', + credentials: 'omit', + }); + + if (!response.ok) { + throw new Error( + `Failed to fetch asset at ${url}: ${response.status} ${response.statusText}`, + ); + } + + return await response.blob(); + } catch (error) { + if ( + error instanceof Error && + error.message.includes('Failed to fetch asset') + ) { + throw error; + } + throw new Error( + `Failed to fetch asset at ${url}: ${error instanceof Error ? error.message : 'Unknown error'}`, + ); + } + }, + }); const pdfDocument = await exporter.toReactPDFDocument(editor.document);