From f49b94788409721621c9386ee69c9c377c3af937 Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Thu, 21 Dec 2023 11:12:57 +0100 Subject: [PATCH] Fix multiple origins issue --- virtweb_backend/src/app_config.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/virtweb_backend/src/app_config.rs b/virtweb_backend/src/app_config.rs index 4ce9bea..9181120 100644 --- a/virtweb_backend/src/app_config.rs +++ b/virtweb_backend/src/app_config.rs @@ -134,14 +134,19 @@ impl AppConfig { /// Get auth cookie domain pub fn cookie_domain(&self) -> Option { - let domain = self.website_origin.split_once("://")?.1; - Some( - domain - .split_once(':') - .map(|s| s.0) - .unwrap_or(domain) - .to_string(), - ) + if cfg!(debug_assertions) { + let domain = self.website_origin.split_once("://")?.1; + Some( + domain + .split_once(':') + .map(|s| s.0) + .unwrap_or(domain) + .to_string(), + ) + } else { + // In release mode, the web app is hosted on the same origin as the API + None + } } /// Get app secret