fix(portal): serve signed PDF in viewer after document is signed

When signedFilePath is set, /api/documents/[id]/file now returns the
signed PDF so agent sees embedded signatures and initials in the portal
viewer. Falls back to original PDF when not yet signed.
This commit is contained in:
Chandler Copeland
2026-03-21 13:25:26 -06:00
parent 50f082d20f
commit a5173fe455

View File

@@ -21,8 +21,9 @@ export async function GET(
}); });
if (!doc || !doc.filePath) return new Response('Not found', { status: 404 }); if (!doc || !doc.filePath) return new Response('Not found', { status: 404 });
// Serve the original unsigned PDF only — see LEGAL-03 // Serve signed PDF to agent when available (LEGAL-03 applies to client-facing endpoints only)
const relativePath = doc.filePath; // Fall back to original if not yet signed
const relativePath = doc.signedFilePath ?? doc.filePath;
const filePath = path.join(UPLOADS_BASE, relativePath); const filePath = path.join(UPLOADS_BASE, relativePath);
// Path traversal guard — critical security check // Path traversal guard — critical security check