diff --git a/src/server/main.rs b/src/server/main.rs index d68ce71..4a23283 100644 --- a/src/server/main.rs +++ b/src/server/main.rs @@ -22,6 +22,14 @@ pub fn main() -> Result { .map_err(|e| Error::message_here(e.to_string())) .err_context("Failed to load config")?; + // Dioxus doesn't expose a way to configure the public path other than this environment + // variable, and also doesn't provide a way to read what the public path is. As a workaround we + // expose a config option and set this variable that Dioxus expects. + // SAFETY: "This function is safe to call in a single-threaded program." + unsafe { + std::env::set_var("DIOXUS_PUBLIC_PATH", config.server.public_path.clone()); + } + // `Ok(...?)` is because `dioxus::serve` expects an `anyhow::Result` dioxus::serve(move || { let config = config.clone();