SPA Routing Basics
Understand why refresh can return 404 in React/Vue SPA and how fallback routing fixes it.
Core concepts
- SPA: Single-page app where routing is handled in browser
- Client-side routing: Router library controls path changes
- Fallback: Server returns index.html for app routes
Why refresh gives 404
On refresh, browser requests current path from server directly. If server has no matching file, you get 404.
Fix direction
- Add SPA fallback rule in hosting config
- Separate static assets and app routes correctly
Practical troubleshooting