{
    auto_https off
    https_port 8443
}

:80 {
    # API routes
    handle_path /api/* {
        reverse_proxy app:8080
    }

    # WebSocket gateway
    handle /ws {
        reverse_proxy app:8080 {
            header_up Connection {>Connection}
            header_up Upgrade {>Upgrade}
        }
    }

    # LiveKit (if proxied)
    handle_path /livekit/* {
        reverse_proxy livekit:7880
    }

    # SPA fallback - serve index.html for all other routes
    handle {
        root * /srv/web
        try_files {path} /index.html
        file_server
    }
}
