diff --git a/src/server/config.rs b/src/server/config.rs index 674a9af..e1c87c4 100644 --- a/src/server/config.rs +++ b/src/server/config.rs @@ -235,6 +235,32 @@ impl Config { .set_default("auth.cookies_secure", DEFAULT_COOKIES_SECURE)? .set_default("server.public_path", default_public_dir()) } + + /// Log any configuration-related warning messages, such as differences between user-configured + /// values and those supplied by the Dioxus CLI + pub fn log_warnings(&self) { + if let Some(dx_port) = dioxus::cli_config::server_port() + && dx_port != self.server.port + { + tracing::warn!( + "Your configured server port ({}) doesn't match the one specified from environment \ + variables set by the Dioxus CLI ({dx_port}). If you are intending to use the dx tool, \ + please do not specify a port in the configuration.", + self.server.port + ); + } + + if let Ok(dx_public_path) = std::env::var("DIOXUS_PUBLIC_PATH") + && dx_public_path != self.server.public_path + { + tracing::warn!( + "Your configured server public path ({}) doesn't match the one specified from environment \ + variables set by the Dioxus CLI ({dx_public_path}). If you are intending to use the dx tool, \ + please do not specify a public_path in the configuration.", + self.server.public_path.display() + ); + } + } } /// Provide a sane default for the public path, using the same sources as Dioxus does internally. diff --git a/src/server/main.rs b/src/server/main.rs index d216947..8ac0adc 100644 --- a/src/server/main.rs +++ b/src/server/main.rs @@ -1,5 +1,4 @@ use dioxus::{ - cli_config, fullstack::axum::{self, Router, middleware::from_fn}, prelude::{DioxusRouterExt, ServeConfig}, server::axum::Extension, @@ -26,6 +25,7 @@ pub async fn main() -> Result { .err_context("Failed to load config")?; tracing::debug!("Loaded configuration: {config:#?}"); + config.log_warnings(); // 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 @@ -59,18 +59,6 @@ pub async fn main() -> Result { let auth_layer = build_auth_layer(db_pool.clone(), key_val_pool, config.auth.cookies_secure); - #[cfg(debug_assertions)] - if let Some(dx_port) = cli_config::server_port() - && dx_port != config.server.port - { - tracing::warn!( - "Your configured server port ({}) doesn't match the one specified from environment \ - variables set by the Dioxus CLI ({dx_port}). If you are intending to use the dx tool, \ - please do not specify a port in the configuration.", - config.server.port - ); - } - let addr = config.server.serve_addr(); tracing::info!("Setup complete, building router...");