#4034·leptos

Leptos router matches requests with trailing slashes for routes defined without them, while axum does not

Author: MikeOnTeaCreated May 31, 2025Updated Sep 20, 2026

I'm opening this issue as a kind of reminder, as workarounds for the problem exist.

When there's a route without trailing slash, and a corresponding request with a trailing slash, axum does not match them, and thus will invoke the leptos error handler and set the response status to 404. The error handler routes the request through the leptos router, which matches the route without the trailing slash, and cause it to render the route instead of the fallback. This can additionally crash the server if the routed view expects context to be present but the error handler does not load it.

Not sure what the ideal solutions would be (adding additional routes to axum, or making the leptos router more strict, or make it configurable again), but in the end the leptos router and the underlying http server should have a common routing table/matching behaviour.

Leptos Dependencies Leptos 0.8.2