From 5d5d86c533e9d7bd7818bb60c2256146b60f0b4e Mon Sep 17 00:00:00 2001 From: agent Date: Sun, 27 Sep 2026 09:37:15 +0000 Subject: [PATCH] Fix imported PDFs not rendering in the Docker image nginx has no MIME type for .mjs, so the pdf.js worker was served as application/octet-stream and browsers refused to load it. Every imported PDF page then showed "Source PDF ... is not available", which looked like missing files. Serve .mjs as text/javascript. The page background now also tells the two failures apart: "not stored on this device" when the source bytes are missing, and "could not display" (with the error logged) when pdf.js fails. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VsorPV3JeJRoZ1mD1pdvtL --- docker/nginx.conf | 6 ++++++ src/lib/components/PdfBackground.svelte | 22 ++++++++++++++-------- src/lib/pdf/render.ts | 5 ++++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/docker/nginx.conf b/docker/nginx.conf index f86d149..bee09c1 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -1,3 +1,9 @@ +# This file is included at http level, so this adds to nginx's MIME table. +# Browsers refuse to run module scripts (the pdf.js worker) served as octet-stream. +types { + text/javascript mjs; +} + server { listen 80; server_name _; diff --git a/src/lib/components/PdfBackground.svelte b/src/lib/components/PdfBackground.svelte index 4c070ba..3d3494e 100644 --- a/src/lib/components/PdfBackground.svelte +++ b/src/lib/components/PdfBackground.svelte @@ -1,5 +1,5 @@ - -{#if failed} -
Source PDF “{origin.name}” is not available
+ +{#if failure === 'missing'} +
Source PDF “{origin.name}” is not stored on this device
+{:else if failure === 'error'} +
Could not display “{origin.name}” (see the browser console)
{/if}