server {
    listen 80;
    server_name localhost;

    # Allow large file uploads
    client_max_body_size 10G;

    # Root directory for the built Vue.js application
    root /usr/share/nginx/html;
    index index.html;

    # API proxy
    location /api/ {
        proxy_pass http://board-api:48889;
        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;
    }

    # Organization API proxy (no /api prefix)
    location /org/ {
        proxy_pass http://board-api:48889;
        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;
    }

    # SPA fallback for all other routes
    location / {
        try_files $uri $uri/ /index.html;
    }
}
