fix: 兼容 base_url 末尾斜杠,避免拼接产生双斜杠导致 404

anthropic.rs 和 openai.rs 在构造时 trim_end_matches('/'),兼容如 https://opencode.ai/zen/go/v1/ 带末尾斜杠的 base_url。
This commit is contained in:
oudecheng 2026-07-07 14:14:20 +08:00
parent 4da7b5f505
commit f264a7b307
2 changed files with 7 additions and 0 deletions

View File

@ -159,6 +159,9 @@ impl AnthropicProvider {
.build()
.unwrap_or_else(|_| Client::new());
// 兼容带末尾斜杠的 base_url避免 format!("{}/v1/messages", base_url) 产生双斜杠
let base_url = base_url.trim_end_matches('/').to_string();
Self {
client,
name,

View File

@ -263,6 +263,10 @@ impl OpenAIProvider {
.build()
.unwrap_or_else(|_| Client::new());
// 兼容带末尾斜杠的 base_url如 https://opencode.ai/zen/go/v1/
// 否则 format!("{}/chat/completions", base_url) 会产生双斜杠导致 404
let base_url = base_url.trim_end_matches('/').to_string();
Self {
client,
name,