diff options
author | Carpenter, Adam (CORP) <Adam.Carpenter@adp.com> | 2021-10-12 15:16:22 -0400 |
---|---|---|
committer | Carpenter, Adam (CORP) <Adam.Carpenter@adp.com> | 2021-10-12 15:16:22 -0400 |
commit | fa113296cc4e1e30dd9b523fdafffdedc0f8b9cc (patch) | |
tree | c7fa3e422b5fdb300f9110365e3ac3135b18265d | |
parent | d8aa76522cc078b5784c94843be37f2875ad5966 (diff) | |
download | altruistic-angelshark-fa113296cc4e1e30dd9b523fdafffdedc0f8b9cc.tar.xz altruistic-angelshark-fa113296cc4e1e30dd9b523fdafffdedc0f8b9cc.zip |
fix: better error handling on env var origin
-rw-r--r-- | angelsharkd/src/config.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/angelsharkd/src/config.rs b/angelsharkd/src/config.rs index b0866be..d7d18d2 100644 --- a/angelsharkd/src/config.rs +++ b/angelsharkd/src/config.rs @@ -23,7 +23,13 @@ impl Config { .unwrap_or_else(|_| Ok(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080))) .with_context(|| "Failed to parse socket bind address.")?; - let origin = env::var("ANGELSHARKD_ORIGIN").unwrap_or_default(); + let origin = if debug_mode { + String::new() + } else { + env::var("ANGELSHARKD_ORIGIN").with_context(|| { + "In release mode, CORS origin cannot be blank. Set ANGELSHARKD_ORIGIN" + })? + }; let logins = if let Ok(path) = env::var("ANGELSHARKD_LOGINS") { File::open(path) |