server {
    listen 80;
    server_name _;

    root /usr/share/nginx/html;
    index index.html;

    # Security headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;

    # Gzip
    gzip on;
    gzip_vary on;
    gzip_types text/plain text/css text/javascript application/javascript application/json image/svg+xml;
    gzip_min_length 1024;
    gzip_comp_level 6;

    # JSX files — force correct MIME type (not in nginx default mime.types)
    location ~* \.jsx$ {
        types { }
        default_type application/javascript;
        expires 1d;
        add_header Cache-Control "public, must-revalidate";
        try_files $uri =404;
    }

    # Cache other static assets
    location ~* \.(css|js|woff2?|ttf|svg|png|jpg|jpeg|ico|gif|webp)$ {
        expires 7d;
        add_header Cache-Control "public, immutable";
        try_files $uri =404;
    }

    # All routes → index.html (SPA / static)
    location / {
        try_files $uri $uri/ /index.html;
    }
}
