From fa113296cc4e1e30dd9b523fdafffdedc0f8b9cc Mon Sep 17 00:00:00 2001 From: "Carpenter, Adam (CORP)" Date: Tue, 12 Oct 2021 15:16:22 -0400 Subject: fix: better error handling on env var origin --- angelsharkd/src/config.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'angelsharkd/src') 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) -- cgit v1.2.3