From acd99f04cea6a22c43e6bfc1ecb49f42e0ebaa39 Mon Sep 17 00:00:00 2001 From: renee-png Date: Wed, 17 Jun 2026 23:08:08 -0400 Subject: [PATCH] Avria Sign: fix PDF not rendering (field placement + signer page) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pdf.js worker was set via new URL("pdfjs-dist/build/pdf.worker.min.mjs", import.meta.url) — Vite only resolves relative paths there, so a bare node_modules specifier 404s in production and react-pdf never renders the PDF (both the field-placement step and the recipient signing page). Switch to a Vite `?url` import so the worker is emitted as a hashed same-origin asset. Co-Authored-By: Claude Opus 4.8 --- src/components/SignatureFieldPlacer.tsx | 10 +++++----- src/pages/PublicSignPage.tsx | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/SignatureFieldPlacer.tsx b/src/components/SignatureFieldPlacer.tsx index 7545437..3cf84d3 100644 --- a/src/components/SignatureFieldPlacer.tsx +++ b/src/components/SignatureFieldPlacer.tsx @@ -5,12 +5,12 @@ import { Badge } from "@/components/ui/badge"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { ChevronLeft, ChevronRight, X, Pen, Calendar as CalIcon, User as UserIcon } from "lucide-react"; import { cn } from "@/lib/utils"; +import pdfWorkerUrl from "pdfjs-dist/build/pdf.worker.min.mjs?url"; -// Use the bundled worker -pdfjs.GlobalWorkerOptions.workerSrc = new URL( - "pdfjs-dist/build/pdf.worker.min.mjs", - import.meta.url -).toString(); +// Use the bundled worker. The `?url` import lets Vite emit the worker as a +// hashed asset and return its real URL; `new URL("pdfjs-dist/...", import.meta.url)` +// does NOT resolve bare node_modules specifiers and 404s in production. +pdfjs.GlobalWorkerOptions.workerSrc = pdfWorkerUrl; export interface PlacedField { id: string; diff --git a/src/pages/PublicSignPage.tsx b/src/pages/PublicSignPage.tsx index bdaae99..1731b53 100644 --- a/src/pages/PublicSignPage.tsx +++ b/src/pages/PublicSignPage.tsx @@ -8,11 +8,12 @@ import { useToast } from "@/hooks/use-toast"; import { FileSignature, CheckCircle2, Loader2, Download, Ban, ChevronLeft, ChevronRight } from "lucide-react"; import SignaturePad from "@/components/SignaturePad"; import { format } from "date-fns"; +import pdfWorkerUrl from "pdfjs-dist/build/pdf.worker.min.mjs?url"; -pdfjs.GlobalWorkerOptions.workerSrc = new URL( - "pdfjs-dist/build/pdf.worker.min.mjs", - import.meta.url -).toString(); +// Vite emits the worker as a hashed asset and returns its real URL. The prior +// `new URL("pdfjs-dist/...", import.meta.url)` does not resolve a bare +// node_modules specifier and 404s in production, so the PDF never renders. +pdfjs.GlobalWorkerOptions.workerSrc = pdfWorkerUrl; interface Field { id: string;