diff --git a/server/presenters/document.js b/server/presenters/document.js index 4650b708..764249be 100644 --- a/server/presenters/document.js +++ b/server/presenters/document.js @@ -18,8 +18,10 @@ async function replaceImageAttachments(text) { for (const id of attachmentIds) { const attachment = await Attachment.findByPk(id); - const accessUrl = await getSignedImageUrl(attachment.key); - text = text.replace(attachment.redirectUrl, accessUrl); + if (attachment) { + const accessUrl = await getSignedImageUrl(attachment.key); + text = text.replace(attachment.redirectUrl, accessUrl); + } } return text;