elastic-transport-python icon indicating copy to clipboard operation
elastic-transport-python copied to clipboard

Use path_prefix to compute base_url in httpx

Open vruello opened this issue 7 months ago • 4 comments
trafficstars

Currently, the path_prefix configuration (i.e. the url path) of the ES host is removed by the httpx client. This PR adds it.

path_prefix is set by client_utils.url_to_node_config (https://github.com/elastic/elastic-transport-python/blob/main/elastic_transport/client_utils.py#L187). It is either "" if the url path is empty or "/", or the url path itself.

For example, if you configure host to be http://localhost:9092/test and run a search() query, you'll see an HTTP request sent to http://localhost:9092/_search, without the "test" prefix.

This is very useful when elastic endpoints are behind a reverse proxy with a specific path.

vruello avatar Apr 17 '25 15:04 vruello

💚 CLA has been signed

Thank you! Can you please sign the CLA?

pquentin avatar Apr 18 '25 12:04 pquentin

Hi! Sorry for the delay. I just signed the CLA.

vruello avatar Apr 30 '25 14:04 vruello

By the way, do you think this commit could be backported to 8.x?

vruello avatar Apr 30 '25 14:04 vruello