server {
    listen 80;
    server_name gcic.tricsofthub.org;
    client_max_body_size 100M;
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-XSS-Protection "1; mode=block" always;
    
    root /var/www/html;
    index index.html index.htm;
    
    # React static files (JS, CSS, images)
    location /client/static/ {
        alias /var/www/html/static/;
        expires 1y;
        add_header Cache-Control "public, immutable";
    }

    # React assets (favicon, manifest, etc.)
    location /client/ {
    alias /var/www/html/;
    try_files $uri $uri/ /client/index.html;
    index index.html;
    }

    # Django static files
    location /static/ {
        alias /staticfiles/;
        expires 1y;
        add_header Cache-Control "public, immutable";
    }

    # Django media files
    location /media/ {
        alias /mediafiles/;
        expires 1y;
        add_header Cache-Control "public, immutable";
    }

    # Django API endpoints
    location /api/ {
        proxy_pass http://django_backend;
        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;
    }
    
    # Django admin
    location /admin/ {
        proxy_pass http://django_backend;
        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;
    }
}

upstream django_backend {
    server client-backend:8794; 
    }