# admin.YOUR-DOMAIN.com → Nuxt dashboard (SPA on localhost:3001)
# The dashboard calls the API via "/api" (same origin), so we proxy it to the
# Laravel backend through PHP-FPM directly (no DNS dependency).
server {
    listen 80;
    server_name admin.YOUR-DOMAIN.com;

    client_max_body_size 20M;

    # API calls from the dashboard → Laravel backend (PHP-FPM)
    location /api/ {
        fastcgi_pass unix:/run/php/php8.4-fpm.sock;
        fastcgi_param SCRIPT_FILENAME /var/www/jamra/backend/public/index.php;
        include fastcgi_params;
    }

    # Dashboard SPA
    location / {
        proxy_pass http://127.0.0.1:3001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        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;
        proxy_cache_bypass $http_upgrade;
    }
}