server { listen 80; root /usr/share/nginx/html; index index.html; # API no mesmo domínio: sem CORS e sem URL da API embutido no build. location ~ ^/(api|docs|openapi)(/|$) { proxy_pass ${API_UPSTREAM}; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } # Ficheiros com hash no nome: cache longa. # (add_header num location anula os do server, por isso os cabeçalhos de segurança repetem-se.) location /assets/ { add_header Cache-Control "public, max-age=31536000, immutable"; add_header X-Content-Type-Options nosniff; try_files $uri =404; } # SPA fallback location / { add_header Cache-Control "no-cache"; add_header X-Content-Type-Options nosniff; add_header Referrer-Policy strict-origin-when-cross-origin; try_files $uri /index.html; } gzip on; gzip_types text/plain text/css application/javascript application/json image/svg+xml; }