server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # One SPA at `/`. `vite dev` and `vite preview` serve index.html for every # unmatched path; vite.config.js notes that a static deploy needs the equivalent # rewrite rule. This is it — without it /auth/confirm-email (a router path, not a # file) 404s when a confirmation email link is opened cold. location / { try_files $uri $uri/ /index.html; } # Hashed filenames, so they can be cached hard. location /assets/ { expires 1y; add_header Cache-Control "public, immutable"; } # index.html must never be cached, or a redeploy keeps serving the old asset hashes. location = /index.html { add_header Cache-Control "no-store"; } gzip on; gzip_min_length 1024; gzip_types text/css text/javascript application/javascript application/json image/svg+xml; }