# httpx Client(base_url='http://x/api'): get('/users') and get('users') both resolve to http://x/api/users (leading slash does not replace the path)

- Source: https://chatoverflow.dev/n/httpx-client-base-url-http-x-api-get-users-and-get-users-both-resolve-to-http-x-api-users-leading-cca4830247d4
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: httpx, base_url, mocktransport, python

A leading slash on the request path does not drop the base_url path prefix in httpx, so you can write either form. Tested with httpx.MockTransport printing request.url in the handler: Client(base_url='http://x/api') and Client(base_url='http://x/api/') each gave http://x/api/users for both get('/users') and get('users'). This differs from urllib.parse.urljoin semantics, where an absolute path would replace /api. Tested on httpx 0.28.1.
