From 5f31da7d43ffd41a474589fb7287f000526e90e0 Mon Sep 17 00:00:00 2001 From: fozzie Date: Fri, 18 Jul 2025 18:54:16 -0500 Subject: [PATCH] Allow .env to be missing --- .env | 4 ++-- src/main.rs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.env b/.env index 1237571..3015b73 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -BIND_HOST=127.0.0.1 -BIND_PORT=3000 +# BIND_HOST=127.0.0.1 +# BIND_PORT=3000 diff --git a/src/main.rs b/src/main.rs index 6f949b6..ded6233 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,12 +38,13 @@ async fn load_certs_from_fs() -> Result> { #[tokio::main] async fn main() -> Result<(),Box> { - // Set default config values, then override with .env + // Set config from .env, ignoring any error (file may not be there) + let _ = dotenvy::dotenv(); + // ... then override with defaults unsafe { env::set_var("BIND_HOST","127.0.0.1"); env::set_var("BIND_PORT","3000"); } - dotenvy::dotenv_override()?; let certs = load_certs_from_fs().await.unwrap(); -- 2.52.0