server
{
    listen 80;
    server_name book.rrbrr.com;
    root /data/ai/frontend/build/h5;
    index index.html;

    # API 请求反向代理到后端
    location /api/ {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    # 静态资源
    location ~ ^/uploads/(.*)$ {
        alias /data/ai/server/uploads/$1;
        expires 7d;
        add_header Cache-Control "public, immutable";
    }

    location ~ ^/audio/(.*)$ {
        alias /data/ai/audio/$1;
        expires 7d;
        add_header Cache-Control "public, immutable";
    }

    location ~ .*\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
    }

    # 其他路由 - Vue SPA fallback
    location / {
        try_files $uri $uri/ /index.html;
    }
}
