diff --git a/apps/sim/app/api/files/export/[id]/route.ts b/apps/sim/app/api/files/export/[id]/route.ts index ba5b436680..cccbe6af1a 100644 --- a/apps/sim/app/api/files/export/[id]/route.ts +++ b/apps/sim/app/api/files/export/[id]/route.ts @@ -86,7 +86,20 @@ export const GET = withRouteHandler( MAX_EMBEDDED_IMAGES ) - logger.info('Exporting markdown with embedded images', { id, imageCount: imageIds.length }) + logger.info('Exporting markdown', { id, imageCount: imageIds.length }) + + if (imageIds.length === 0) { + const mdName = safeFilename(record.originalName) + const mdBytes = Buffer.from(mdContent, 'utf-8') + return new NextResponse(new Uint8Array(mdBytes), { + status: 200, + headers: { + 'Content-Type': 'text/markdown; charset=utf-8', + 'Content-Disposition': `attachment; filename="${mdName}"`, + 'Content-Length': String(mdBytes.length), + }, + }) + } const fetchResults = await Promise.allSettled( imageIds.map(async (imageId) => {