SPA routing returns 404 for Dioxus client-side routes #14
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
hero_os_http serves the Dioxus WASM frontend. Dioxus uses HTML5 pushState for client-side routing, meaning the browser URL changes without actual page loads (e.g.
/hero_os_http/settings).When the user refreshes on a client-side route, or navigates directly to one, the server looks for a matching file and returns 404 because no such file exists on disk.
Current Behavior
Refreshing or directly navigating to any Dioxus route (e.g.
/hero_os_http/) returns 404 instead of serving the SPA.Expected Behavior
All paths that don't match a real asset file should return
index.html, allowing Dioxus to handle routing on the client side.Fix
Serve
/assets/*and/hero_os_http/assets/*fromServeDir, and usefallback_service(ServeFile::new(index.html))for everything else. This is the standard SPA server pattern.