Merge pull request #537 from JunioCalu/make-embed-frontend-optional

fix embed frontend optional
This commit is contained in:
jb-alvarado 2024-02-21 14:25:52 +01:00 committed by GitHub
commit 02b4e9d964
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -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"),
);
}

View File

@ -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/")
}