server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Without the trailing slash, redirect so relative asset paths resolve. location = /v2 { return 301 /v2/; } # React Router SPA under /v2 — fall back to index.html for client routes. location /v2/ { try_files $uri $uri/ /v2/index.html; } # Root convenience redirect to the SPA entry. location = / { return 302 /v2/; } # Long-cache hashed assets emitted by Vite. location ~* /v2/assets/ { expires 1y; add_header Cache-Control "public, immutable"; } }