diff --git a/Cargo.toml b/Cargo.toml index cc9f3e5..1116650 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rust-version = "1.86" axum = { version = "0.7", features = ["macros"] } tokio = { version = "1", features = ["macros", "rt-multi-thread", "time", "signal"] } tower = { version = "0.5", features = ["util"] } -tower-http = { version = "0.5", features = ["cors", "fs", "trace"] } +tower-http = { version = "0.5", features = ["cors", "fs", "trace", "limit"] } hyper = { version = "1.0", features = ["full"] } # HTTP 客户端(上游转发) diff --git a/src/main.rs b/src/main.rs index 64727fe..6ecb806 100644 --- a/src/main.rs +++ b/src/main.rs @@ -210,6 +210,11 @@ async fn main() -> anyhow::Result<()> { let state = routes::AppState::new(conn, cfg, crypto); let app = routes::router() .with_state(state) + // 请求体上限:axum 默认 2MB,对超长 LLM 上下文/图片 base64 不够,放宽到 70MB + //(rant 2026-08-22T23:20:00;真实限制仍由上游模型 context 窗口裁决) + .layer(tower_http::limit::RequestBodyLimitLayer::new( + 70 * 1024 * 1024, + )) .layer(tower_http::trace::TraceLayer::new_for_http()); let listener = tokio::net::TcpListener::bind(&addr).await?;