From 4d26c01df83f8c4cd12f5f2f804e0780e89c8df4 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 11 Oct 2023 14:50:47 +0200 Subject: [PATCH] handle default base_url in instance settings --- backend/src/monitor.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/backend/src/monitor.rs b/backend/src/monitor.rs index 668cf3ebbf792..26006f9cdebae 100644 --- a/backend/src/monitor.rs +++ b/backend/src/monitor.rs @@ -505,22 +505,25 @@ pub async fn reload_base_url_setting(db: &DB) -> error::Result<()> { .fetch_optional(db) .await?; + let std_base_url = std::env::var("BASE_URL") + .ok() + .unwrap_or_else(|| "http://localhost".to_string()); let base_url = if let Some(q) = q_base_url { if let Ok(v) = serde_json::from_value::(q.value.clone()) { - v + if v != "" { + v + } else { + std_base_url + } } else { tracing::error!( "Could not parse base_url setting as a string, found: {:#?}", &q.value ); - std::env::var("BASE_URL") - .ok() - .unwrap_or_else(|| "http://localhost".to_string()) + std_base_url } } else { - std::env::var("BASE_URL") - .ok() - .unwrap_or_else(|| "http://localhost".to_string()) + std_base_url }; let q_oauth = sqlx::query!(