Set DIOXUS_PUBLIC_PATH to configured value

This commit is contained in:
2026-06-30 21:11:26 -04:00
parent c9b7bbfece
commit f41f4f8d80

View File

@@ -22,6 +22,14 @@ pub fn main() -> Result<std::convert::Infallible> {
.map_err(|e| Error::message_here(e.to_string())) .map_err(|e| Error::message_here(e.to_string()))
.err_context("Failed to load config")?; .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` // `Ok(...?)` is because `dioxus::serve` expects an `anyhow::Result`
dioxus::serve(move || { dioxus::serve(move || {
let config = config.clone(); let config = config.clone();