diff --git a/src/lib.rs b/src/lib.rs index 3394a4e..f5edf7a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,4 +10,15 @@ pub use views::*; use std::{path::PathBuf, sync::LazyLock}; -pub static CACHE_DIR: LazyLock = LazyLock::new(|| PathBuf::from("/var/lib/nyazoom/cache")); +pub static CACHE_DIR: LazyLock = LazyLock::new(|| { + std::env::var("CACHE_DIR") + .ok() + .map(PathBuf::from) + .unwrap_or_else(|| PathBuf::from("/var/lib/nyazoom/cache")) +}); +pub static DIST_DIR: LazyLock = LazyLock::new(|| { + std::env::var("DIST_DIR") + .ok() + .map(PathBuf::from) + .unwrap_or_else(|| PathBuf::from("./dist")) +}); diff --git a/src/main.rs b/src/main.rs index 91d0482..20271de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,7 +34,7 @@ async fn main() -> io::Result<()> { .nest("/records", get_records_router()) .nest("/link", get_link_router()) .with_state(state) - .fallback_service(ServeDir::new("dist")) + .fallback_service(ServeDir::new(&*DIST_DIR)) .layer(TraceLayer::new_for_http()) .layer(middleware::from_fn(log_source));