Skip to content

Commit

Permalink
handle default base_url in instance settings
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfiszel committed Oct 11, 2023
1 parent e088ec5 commit 4d26c01
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions backend/src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down

0 comments on commit 4d26c01

Please sign in to comment.