Files
TehRiehlDeal 8e1bac5430
CI / vuln-scan (push) Successful in 14s
CI / sast (push) Successful in 10s
CI / test (push) Successful in 26s
CI / lint (push) Successful in 28s
CI / secrets-scan (push) Successful in 5s
CI / build-images (push) Successful in 1m57s
CI / image-scan (push) Successful in 50s
CI / push (push) Successful in 32s
Bundle PDF.js worker via Vite ?worker so it ships as a .js asset
Production deploy returned the worker module with
Content-Type: application/octet-stream — nginx's bundled mime.types
doesn't map .mjs and X-Content-Type-Options: nosniff stopped Firefox
from executing it, so PDFs failed with "Setting up fake worker failed".

Switch the worker import from ?url to ?worker and assign workerPort, so
Vite emits the worker as a regular hashed .js chunk that nginx already
serves correctly. Also add a nginx fallback that maps .mjs to
text/javascript for any future module assets, and include text/javascript
in gzip_types.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 23:21:35 -07:00

50 lines
1.5 KiB
Nginx Configuration File

server {
listen 8080;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Compress text-ish assets on the fly
gzip on;
gzip_types text/plain text/css text/javascript application/javascript application/json image/svg+xml;
gzip_min_length 1024;
# nginx's bundled mime.types in this image still maps `.mjs` to
# application/octet-stream, which browsers refuse to execute as a module
# (especially with X-Content-Type-Options: nosniff). Force the JS MIME
# type for any `.mjs` so module workers / dynamic imports work.
location ~* \.mjs$ {
types { } default_type text/javascript;
add_header Cache-Control "public, max-age=31536000, immutable" always;
try_files $uri =404;
}
# Block dotfiles served from the static root
location ~ /\. {
deny all;
}
# Runtime config is rewritten at every container start; never cache it
location = /config.js {
add_header Cache-Control "no-store" always;
try_files $uri =404;
}
# index.html must always be revalidated so a deploy is picked up
location = /index.html {
add_header Cache-Control "no-store" always;
try_files $uri =404;
}
# Vite emits hashed filenames into /assets — safe to cache aggressively
location /assets/ {
add_header Cache-Control "public, max-age=31536000, immutable" always;
try_files $uri =404;
}
# SPA fallback: route everything else through index.html
location / {
try_files $uri $uri/ /index.html;
}
}