DioxusLabs/dioxus · error

Failed to parse index.html from public directory

Error message

Failed to parse index.html from public directory

What it means

`ServeConfig::new` parses the public directory's `index.html` to inject server-side placeholders; this error fires if the file exists but is not parseable as the expected HTML form. The malformed index.html in the public dir is at fault; use `with_index_html` to supply a valid one.

Solutions

  1. Fix index.html in the public directory so it parses as valid HTML with the structure the server expects (including head/body).
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/fullstack-server/src/config.rs:64 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/e6125e0fcfa8eb5c. Report an issue: GitHub.

Appendix: source

Thrown at packages/fullstack-server/src/config.rs:64

    }

    /// Create a new ServeConfig with incremental static generation disabled and the default index.html settings
    ///
    /// This will automatically use the `index.html` file in the `/public` directory if it exists.
    /// The `/public` folder is meant located next to the current executable. If no `index.html` file is found,
    /// a default index.html will be used, which will not include any JavaScript or WASM initialization code.
    ///
    /// To provide an alternate `index.html`, you can use `with_index_html` method instead.
    pub fn new() -> Self {
        let index = if let Some(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");

                IndexHtml::new(&index_html, "main")
                    .expect("Failed to parse index.html from public directory")
            } else {
                IndexHtml::ssr_only()
            }
        } else {
            tracing::warn!(
                "Cannot identify public directory, using default index.html. If you need client-side scripts (like JS + WASM), please provide an explicit public directory."
            );
            IndexHtml::ssr_only()
        };

        Self {
            index,
            incremental: None,
            context_providers: Default::default(),
            streaming_mode: StreamingMode::default(),
        }
    }

View on GitHub (pinned to 24f6a829df)