SPA routing returns 404 for Dioxus client-side routes #14

Closed
opened 2026-02-28 15:22:57 +00:00 by mik-tf · 0 comments
Owner

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/* from ServeDir, and use fallback_service(ServeFile::new(index.html)) for everything else. This is the standard SPA server pattern.

## 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/*` from `ServeDir`, and use `fallback_service(ServeFile::new(index.html))` for everything else. This is the standard SPA server pattern.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_os#14
No description provided.