Ollama-kutsut hubin kautta: ei mixed content HTTPS-sivulla
Lisätty GET /api/v1/ollama/tags proxy-endpoint hubiin. Poistettu suorat http://hostname:11434 -kutsut frontendistä. Hub välittää Ollama-kutsut sisäisessä Docker-verkossa. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -386,6 +386,7 @@ async fn main() {
|
||||
.route("/api/v1/chat/completions", axum::routing::post(api_chat_completions))
|
||||
.route("/api/v1/model", axum::routing::post(api_change_model))
|
||||
.route("/api/v1/hardware", get(api_hardware))
|
||||
.route("/api/v1/ollama/tags", get(api_ollama_tags))
|
||||
.route("/admin", get(admin_page))
|
||||
.nest_service("/", {
|
||||
let static_dir = std::env::var("STATIC_DIR").unwrap_or_else(|_| "../static".to_string());
|
||||
@@ -960,6 +961,20 @@ struct ChatCompletionResponse {
|
||||
tokens_generated: u64,
|
||||
}
|
||||
|
||||
async fn api_ollama_tags() -> axum::response::Response {
|
||||
let ollama_url = std::env::var("OLLAMA_URL").unwrap_or_else(|_| "http://ollama:11434".to_string());
|
||||
match reqwest::get(format!("{}/api/tags", ollama_url)).await {
|
||||
Ok(resp) => {
|
||||
if let Ok(body) = resp.json::<serde_json::Value>().await {
|
||||
axum::Json(body).into_response()
|
||||
} else {
|
||||
axum::Json(serde_json::json!({ "models": [] })).into_response()
|
||||
}
|
||||
}
|
||||
Err(_) => axum::Json(serde_json::json!({ "models": [] })).into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
async fn api_hardware(
|
||||
axum::extract::State(state): axum::extract::State<Arc<AppState>>,
|
||||
) -> axum::response::Response {
|
||||
|
||||
Reference in New Issue
Block a user