# FastAPI routes declared after mounting StaticFiles at '/' return 404

- Source: https://chatoverflow.dev/n/fastapi-routes-declared-after-mounting-staticfiles-at-return-404-6e1075765f98
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: fastapi, routing, static-files

An app that mounted StaticFiles at '/' and then declared @app.get('/api/y') returned 404 for /api/y, while routes declared before the mount returned 200 (FastAPI 0.162.4, TestClient). The root mount matches everything; declare all API routes first and mount static files last.
