Skip to content

fix(web): publish the pdf.js worker as .js so Amplify serves it (#726) - #736

Merged
biggicode merged 1 commit into
developfrom
vic2/pdf-worker-js
Nov 25, 2026
Merged

biggicode merged 1 commit into
developfrom
vic2/pdf-worker-js

Conversation

@biggicode

Copy link
Copy Markdown
Contributor

On staging the web PDF viewer (#726) always shows „Documentul nu poate fi afișat aici. Îl poți descărca”.

Cause

  • The contract file loads (200).
  • The worker assets/pdf.worker.min-*.mjs comes back as index.html (content-type: text/html).
  • The catch-all rewrite in terraform-ngohub modules/amplify/amplify.tf sends every extension outside css|gif|ico|jpg|js|png|txt|svg|webp|woff|ttf|map|json to index.html, and .mjs is not in that list.
  • pdf.js then logs "Setting up fake worker" and cannot render.
$ curl -sI https://vic-staging.ngohub.ro/assets/pdf.worker.min-qwK7q_zL.mjs
HTTP/2 200
content-type: text/html

Fix
vite.config.ts names .mjs assets .js. The build now emits assets/pdf.worker.min-<hash>.js, PdfDocument points at it, and pdf.js still loads it as a module worker. No infrastructure change is needed on staging or production, and the shared Amplify module (used by NGO Hub and the other sites) stays as it is.

Checked

🤖 Generated with Claude Code

On staging the PDF viewer always fell back to "Documentul nu poate fi
afișat aici": the contract file loaded (200), but the worker
assets/pdf.worker.min-*.mjs came back as index.html (text/html). The
Amplify rewrite in terraform-ngohub modules/amplify sends every extension
outside css|gif|ico|jpg|js|png|txt|svg|webp|woff|ttf|map|json to
index.html, and .mjs is not in the list, so pdf.js fell back to a fake
worker and could not render.

The build now names .mjs assets .js. The worker is still loaded as a
module worker; no infrastructure change is needed on staging or
production.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@biggicode biggicode self-assigned this Nov 25, 2026
@biggicode
biggicode merged commit af31906 into develop Nov 25, 2026
5 checks passed
@biggicode
biggicode deleted the vic2/pdf-worker-js branch November 25, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant