server {
    listen 80;
    server_name rebours.studio;

    # ── API proxy → Fastify ────────────────���─────────────────────────────────
    location /api/ {
        proxy_pass http://127.0.0.1:3000;
        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 https;
    }

    # ── Static assets from Astro client build ──────────────────���─────────────
    location /_astro/ {
        root /var/www/html/rebours/dist/client;
        add_header Cache-Control "public, max-age=31536000, immutable";
    }

    location ~* \.(css|js|jpg|jpeg|png|gif|webp|svg|woff2|woff|ttf|ico|mp3)$ {
        root /var/www/html/rebours/dist/client;
        add_header Cache-Control "public, max-age=604800";
    }

    # ── SSR → Astro Node server ─────────────────────���────────────────────────
    location / {
        proxy_pass http://127.0.0.1:4321;
        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 https;
    }
}
