Fix imported PDFs not rendering in the Docker image #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-pdf-worker"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
In the Docker image, every imported PDF page showed "Source PDF … is not available", even for a PDF imported seconds earlier.
nginx's MIME table has no entry for
.mjs, so the pdf.js worker (pdf.worker.min.mjs) was served asapplication/octet-stream. Browsers refuse to run module scripts with that type, and pdf.js's fallback loads the same file, so it failed too. The dev server serves.mjscorrectly, which is why this only showed up in Docker. No data was missing: source PDFs are embedded in each synced canvas and restored on pull.Fix
docker/nginx.conf: serve.mjsastext/javascript. The file is included at http level, so this adds to nginx's MIME table instead of replacing it.PdfBackground.svelte/render.ts: tell the two failures apart instead of showing one misleading message:Testing
curl: the worker is nowtext/javascriptand keeps its long-term cache header. HTML, JS and the manifest types are unchanged, andnginx -tpasses.application/octet-stream: shows "Could not display".mainimage reproduces the bug: "is not available" and nothing drawn.npm run checkand all 24 unit tests pass.After merging, rebuild on the server with
git pull && docker compose up -d --build, then reload the page (the new service worker takes over on reload).🤖 Generated with Claude Code
https://claude.ai/code/session_01VsorPV3JeJRoZ1mD1pdvtL