- main.tsx: on vite:preloadError (stale index.html referencing removed hashed chunks after a redeploy) reload the page immediately. - New ErrorBoundary around the whole router: render errors show a Persian fallback with «تلاش مجدد» instead of wiping the DOM. - nginx: index.html served with Cache-Control no-cache,no-store, must-revalidate (verified live); /assets/* stays public, immutable.
50 lines
1.9 KiB
Nginx Configuration File
50 lines
1.9 KiB
Nginx Configuration File
# Frontend nginx config
|
|
# - Serves the built SPA from /usr/share/nginx/html
|
|
# - Proxies /api/* to the backend service (Docker compose network name: api)
|
|
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# حداکثر حجم فایلهای آپلودی (فاکتور/پیشفاکتور) — پیشفرض nginx فقط ۱ مگابایت
|
|
# است و آپلودهای بزرگتر با خطای 413 رد میشوند.
|
|
client_max_body_size 50m;
|
|
|
|
# API reverse proxy -> FastAPI backend (port 8000)
|
|
# NOTE: upstream is resolved at REQUEST time through Docker's embedded DNS
|
|
# (127.0.0.11). A plain `proxy_pass http://api:8000` caches the container
|
|
# IP at nginx startup, so after the api container restarts and gets a new
|
|
# IP, nginx keeps proxying to the stale address (which may belong to
|
|
# another service) until this container is restarted too.
|
|
location /api/ {
|
|
resolver 127.0.0.11 valid=10s ipv6=off;
|
|
set $api_upstream http://api:8000;
|
|
proxy_pass $api_upstream;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
# SPA fallback — all client-side routes go to index.html
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# index.html itself must never be cached: after a redeploy the hashed
|
|
# /assets/* names change, and a stale cached HTML would 404 on the old
|
|
# chunks (blank page). Content-hashed assets below stay immutable.
|
|
location = /index.html {
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
}
|
|
|
|
# Static assets cache — hashed filenames are content-addressed
|
|
location /assets/ {
|
|
expires 30d;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
}
|