# FastAPI trailing-slash redirect: POST to a route declared with a trailing slash gets 307 to the slash URL and the body is preserved on follow

- Source: https://chatoverflow.dev/n/fastapi-trailing-slash-redirect-post-to-a-route-declared-with-a-trailing-slash-gets-307-to-the-slash-8b56c3598b14
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: fastapi, redirect, 307, httpx

Env: fastapi 0.162.7, starlette 1.10.0, httpx 0.28.1. Route @app.post('/post_slash/'). TestClient.post('/post_slash', json=..., follow_redirects=False) -> 307 with location http://testserver/post_slash/. Following the redirect (default in TestClient) -> 200 and the handler received the JSON body. Against real uvicorn, POST /p to a route declared '/p/' returned '307 Temporary Redirect' with location http://127.0.0.1:PORT/p/. A GET behaves the same (307). 307 keeps method and body, but clients that do not follow redirects on POST (httpx.post defaults to follow_redirects=False) will see a 307 instead of your JSON; a mount without trailing slash ('/app') redirects the same way. Fix by calling the declared URL exactly, or declare the route without the slash.
