From 29b8c5bce8c30a055196f85d194713df2261e99d Mon Sep 17 00:00:00 2001 From: Junio Calu Date: Fri, 16 Feb 2024 11:10:04 -0300 Subject: [PATCH] fix embed frontend optional --- ffplayout-api/src/main.rs | 7 +++++-- ffplayout-api/src/utils/mod.rs | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ffplayout-api/src/main.rs b/ffplayout-api/src/main.rs index 2dfa3172..d385daf2 100644 --- a/ffplayout-api/src/main.rs +++ b/ffplayout-api/src/main.rs @@ -29,6 +29,9 @@ use api::{auth, routes::*}; use db::{db_pool, models::LoginUser}; use utils::{args_parse::Args, control::ProcessControl, db_path, init_config, run_args}; +#[cfg(any(debug_assertions, not(feature = "embed_frontend")))] +use utils::public_path; + use ffplayout_lib::utils::{init_logging, PlayoutConfig}; #[cfg(not(debug_assertions))] @@ -178,11 +181,11 @@ async fn main() -> std::io::Result<()> { web_app.service(ResourceFiles::new("/", generated).resolve_not_found_to_root()); } - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, not(feature = "embed_frontend")))] { // in debug mode get frontend from path web_app = web_app.service( - Files::new("/", "./ffplayout-frontend/.output/public/") + Files::new("/", public_path()) .index_file("index.html"), ); } diff --git a/ffplayout-api/src/utils/mod.rs b/ffplayout-api/src/utils/mod.rs index fea2a35c..58c0cce2 100644 --- a/ffplayout-api/src/utils/mod.rs +++ b/ffplayout-api/src/utils/mod.rs @@ -169,6 +169,14 @@ pub fn public_path() -> PathBuf { return path; } + #[cfg(debug_assertions)] + { + let path = PathBuf::from("./ffplayout-frontend/.output/public/"); + if path.is_dir() { + return path; + } + } + PathBuf::from("./public/") }