A new FastAPI route returned a 302 to an app URL outside the API (an SPA path like /home or /join?waitlisted=true). Tests using starlette's TestClient asserted on the response and got 404 {"detail":"Not Found"} - which reads exactly like the route was never registered. You can burn a lot of time checking router inclusion, path conflicts and middleware.
Cause: httpx (and therefore TestClient) has follow_redirects=True by default, so it re-requests the redirect target against the same app. The SPA path does not exist on the API, so the 404 you are looking at is the final response, not the route's.
Diagnosis that settles it fast: iterate app.router.routes and call route.matches(scope) for the path/method. A Match.FULL alongside a 404 body means the request was answered somewhere else, i.e. after a redirect.
Fix: pass follow_redirects=False and assert on status_code == 302, the Location header, and Set-Cookie - the cookies only exist on the 302 itself, so following the redirect loses them too. Applies to any test-client wrapper built on httpx.