Avria Sign: fix PDF not rendering (field placement + signer page)

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 <noreply@anthropic.com>
This commit is contained in:
2026-06-17 23:08:08 -04:00
parent 86e8513694
commit acd99f04ce
2 changed files with 10 additions and 9 deletions
+5 -5
View File
@@ -5,12 +5,12 @@ import { Badge } from "@/components/ui/badge";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; 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 { ChevronLeft, ChevronRight, X, Pen, Calendar as CalIcon, User as UserIcon } from "lucide-react";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import pdfWorkerUrl from "pdfjs-dist/build/pdf.worker.min.mjs?url";
// Use the bundled worker // Use the bundled worker. The `?url` import lets Vite emit the worker as a
pdfjs.GlobalWorkerOptions.workerSrc = new URL( // hashed asset and return its real URL; `new URL("pdfjs-dist/...", import.meta.url)`
"pdfjs-dist/build/pdf.worker.min.mjs", // does NOT resolve bare node_modules specifiers and 404s in production.
import.meta.url pdfjs.GlobalWorkerOptions.workerSrc = pdfWorkerUrl;
).toString();
export interface PlacedField { export interface PlacedField {
id: string; id: string;
+5 -4
View File
@@ -8,11 +8,12 @@ import { useToast } from "@/hooks/use-toast";
import { FileSignature, CheckCircle2, Loader2, Download, Ban, ChevronLeft, ChevronRight } from "lucide-react"; import { FileSignature, CheckCircle2, Loader2, Download, Ban, ChevronLeft, ChevronRight } from "lucide-react";
import SignaturePad from "@/components/SignaturePad"; import SignaturePad from "@/components/SignaturePad";
import { format } from "date-fns"; import { format } from "date-fns";
import pdfWorkerUrl from "pdfjs-dist/build/pdf.worker.min.mjs?url";
pdfjs.GlobalWorkerOptions.workerSrc = new URL( // Vite emits the worker as a hashed asset and returns its real URL. The prior
"pdfjs-dist/build/pdf.worker.min.mjs", // `new URL("pdfjs-dist/...", import.meta.url)` does not resolve a bare
import.meta.url // node_modules specifier and 404s in production, so the PDF never renders.
).toString(); pdfjs.GlobalWorkerOptions.workerSrc = pdfWorkerUrl;
interface Field { interface Field {
id: string; id: string;