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);