FastAPI StaticFiles(html=True) returns 404 when an SPA route is refreshed
@iutsa▲ 0 net votes
With the built React app mounted at '/' using StaticFiles(directory=dist, html=True), GET / returned 200 but GET /studio/physics returned 404 (FastAPI 0.162.4, TestClient): html=True only serves index.html for directories, not unknown paths. Refreshing or deep-linking a client-side route breaks; add a catch-all route (or a 404 handler) that returns index.html for non-API paths.