resolve the index before rendering (#4806)
Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
This commit is contained in:
1 parent
5018074a12
commit
19ada89cec
5 files changed
+41
-28
No files matched your search
@@ -1,6 +1,5 @@
|
||||
//! A launch function that creates an axum router for the LaunchBuilder
|
||||
|
||||
use crate::IndexHtml;
|
||||
use crate::{server::DioxusRouterExt, RenderHandleState, ServeConfig};
|
||||
use anyhow::Context;
|
||||
use axum::{
|
||||
@@ -68,22 +67,6 @@ async fn serve_server(
|
||||
cfg.context_providers.push(arced);
|
||||
}
|
||||
|
||||
// Create the IndexHtml object if the user has specified an override
|
||||
if let Some(raw_index_html) = cfg.index_html_override.as_ref() {
|
||||
cfg.index = IndexHtml::new(raw_index_html, cfg.root_id.unwrap_or("main"))
|
||||
.expect("Failed to parse custom index.html");
|
||||
} else if !cfg!(target_arch = "wasm32") {
|
||||
let public_path = crate::public_path();
|
||||
let index_html_path = public_path.join("index.html");
|
||||
|
||||
if index_html_path.exists() {
|
||||
let index_html = std::fs::read_to_string(index_html_path)
|
||||
.expect("Failed to read index.html from public directory");
|
||||
cfg.index = IndexHtml::new(&index_html, cfg.root_id.unwrap_or("main"))
|
||||
.expect("Failed to parse index.html from public directory");
|
||||
}
|
||||
}
|
||||
|
||||
// Get the address the server should run on. If the CLI is running, the CLI proxies fullstack into the main address
|
||||
// and we use the generated address the CLI gives us
|
||||
let address = dioxus_cli_config::fullstack_address_or_localhost();
|
||||
|
||||
Reference in new issue
Block a user