#Router error with initial_route while rendering under dioxus_ssr

1 messages · Page 1 of 1 (latest)

opal pewter
#

Hi - I'm trying to render a simple app on the server side. I'm manually parsing the url into my Route enum and now trying to pass it into the app so the correct route renders. I gisted some of my code here: https://gist.github.com/chanks/f7b080e79dac71e505c3f53ddedca8e3

The dbg! calls are printing out the values I expect - that is, I'm retrieving the correct initial_route in the component, and the config block is running. The problem is that I hit a runtime error:

Message:  index route does not exist:
Route did not match:
Attempted Matches:
1) Route 'Login' ('/login') did not match:
Static segment 'login' did not match instead found ''
2) Route 'Account' ('/account') did not match:
Static segment 'account' did not match instead found ''
3) Route 'Root' ('/~') did not match:
Static segment '~' did not match instead found ''

 use MemoryHistory::with_initial_path or RouterConfig::initial_route to set a custom path

So apparently the dioxus router code isn't finding the initial_route, even though I'm able to confirm that I'm returning a RouterConfig that has it set. I'm not sure why this is happening, any ideas?

Versions: Rust 1.78.0, dioxus-router 0.5.0, dioxus-core-0.5.1

Thanks!

Gist

GitHub Gist: instantly share code, notes, and snippets.

crisp junco
#

Hmm, yeah something weird going on. That seems like a bug

#

Could you open an issue on github?

#

In the meantime, just adding a placeholder index route seems to fix the issue:

#[derive(Clone, Debug, PartialEq, Routable)]
pub enum Route {
    #[route("/login")]
    Login {},
    #[route("/account")]
    Account {},
    #[route("/~")]
    Root {},
    #[route("/")]
    App {},
}
fn App() -> Element {
    todo!()
}
#

It does render the right thing, but somewhere dioxus is assuming you have an index route