SPA routing returns 404 for Dioxus client-side routes #14
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_os#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.