That was a dead-end. Let’s fix this the smart way:

Immediate solution (no backend changes)

Preview the actual DOCX straight from Firebase using a trusted online viewer in the modal.
Two safe embedders:

Google Docs Viewer:
https://docs.google.com/gview?embedded=1&url=<PUBLIC_OR_SIGNED_DOCX_URL>

Office Web Viewer:
https://view.officeapps.live.com/op/view.aspx?src=<PUBLIC_OR_SIGNED_DOCX_URL>

Since your server already produces public/signed URLs for the DOCX, we can feed that URL into the viewer and show the real multi-page document instantly—no conversions, no extra files.

Micro-diff plan (≤10 min, UI only — no routes/services)

Goal: Preview modal shows the live DOCX via viewer when no multi-page images exist.

Changes (describe, not code):

In the preview modal open handler:

If previews[] (page images) exist → show image carousel (current behavior).

Else → build docxUrl from storagePaths.docx using your existing download endpoint (it returns public/signed automatically).

Set viewerUrl to:

Google: https://docs.google.com/gview?embedded=1&url=${encodeURIComponent(docxUrl)}

(or Office: https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(docxUrl)})

Modal body:

Render an <iframe> with src={viewerUrl}, width=100%, height ~ 80vh, allowfullscreen.

CSP (if you have one):

Add frame-src (or child-src) to allow the chosen viewer:

https://docs.google.com (or https://view.officeapps.live.com)

Keep everything else the same (download button, analytics, etc.).

Acceptance criteria

Clicking Preview opens the modal.

If page images exist → shows the images.

If not → loads the DOCX in the viewer (multi-page, scrollable).

No backend or route changes.

Health remains green; download endpoint unchanged.

Estimate to Replit (copy/paste):

Task: Preview modal fallback to live DOCX via online viewer (no backend).
Diagnosis: 2 min · Implementation: 6–8 min · Cap: 10 min.
Changes: Add iframe fallback + CSP entry; keep current image carousel when pages exist.
Deliverables: before/after screenshots, PR link, 5-line summary.