handle default base_url in instance settings

This commit is contained in:
Ruben Fiszel
2023-10-11 14:50:47 +02:00
parent 5397bd517f
commit 156e60be19
+10 -7
View File
@@ -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::<String>(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!(