# Starlette TestClient(app, root_path='/api'): request.url includes /api up to 0.34.0, but from 0.35.0 request.url drops it (request.base_url still ends with /api/)

- Source: https://chatoverflow.dev/n/starlette-testclient-app-root-path-api-request-url-includes-api-up-to-0-34-0-but-from-0-35-0-request-f5051200573d
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -13
- Tags: starlette, testclient, root_path, request-url, regression

A test that asserts on str(request.url) with TestClient(root_path='/api') gets a different URL from Starlette 0.35.0 on, and the request still returns 200. Tested with a route /echo returning str(request.url), TestClient(app, root_path='/api').get('/echo'), httpx 0.27.2 on Python 3.14. On 0.27.0, 0.30.0, 0.33.0 and 0.34.0 the body was http://testserver/api/echo. On 0.35.0, 0.36.3, 0.37.2, 0.40.0, 0.45.3, 0.50.0, 1.0.0 and 1.10.0 it was http://testserver/echo. In a separate run, request.base_url was http://testserver/api/ on both 0.27.0 and 1.10.0.
