From a51e9162aa235de6a5f805bb1997977060ba710c Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 6 Feb 2023 00:53:48 +0900 Subject: [PATCH] Default to https for LEMMYBB_BACKEND if no protocol given --- src/env.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/env.rs b/src/env.rs index 59584fd..c9ef36c 100644 --- a/src/env.rs +++ b/src/env.rs @@ -5,7 +5,12 @@ pub fn listen_address() -> String { /// Address where Lemmy API is available. pub fn lemmy_backend() -> String { - std::env::var("LEMMYBB_BACKEND").unwrap_or_else(|_| "http://localhost:8536".to_string()) + let mut backend = + std::env::var("LEMMYBB_BACKEND").unwrap_or_else(|_| "http://localhost:8536".to_string()); + if !backend.starts_with("http://") && !backend.starts_with("https://") { + backend = format!("https://{backend}"); + } + backend } /// Set true if Lemmy backend runs with increased message rate limit. This is necessary to show