server { listen 5173; listen [::]:5173; server_name _; root /app/dist; index index.html; # Tolerante al comportamiento de Apache (con o sin strip del prefijo): # - Si llega `/orcid2words/...` → strip y servir desde dist/. # - Si llega `/` o cualquier otra ruta → servir SPA igualmente. # `^~` fuerza prioridad sobre cualquier regex y evita sorpresas de matching. # Combinado con el `basename` dinámico de `main.jsx`, React Router se adapta. location ^~ /orcid2words/ { add_header X-Original-URI $request_uri always; add_header X-Resolved-URI $uri always; add_header X-Location-Hit "prefix-orcid2words" always; rewrite ^/orcid2words/(.*)$ /$1 break; try_files $uri $uri/ /index.html; } location = /orcid2words { return 301 /orcid2words/; } location / { add_header X-Original-URI $request_uri always; add_header X-Resolved-URI $uri always; add_header X-Location-Hit "root" always; try_files $uri $uri/ /index.html; } }