X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/d15f6051293251d60d598a25c89e8fc5b6f75d4b..5f09ba4e10b52b5154fb3e9211b8ec5fcfe82d91:/nominatim/server/starlette/server.py diff --git a/nominatim/server/starlette/server.py b/nominatim/server/starlette/server.py index f89e52a1..5567ac9c 100644 --- a/nominatim/server/starlette/server.py +++ b/nominatim/server/starlette/server.py @@ -50,6 +50,19 @@ class ParamWrapper(api_impl.ASGIAdaptor): return Response(output, status_code=status, media_type=self.content_type) + def base_uri(self) -> str: + scheme = self.request.url.scheme + host = self.request.url.hostname + port = self.request.url.port + root = self.request.scope['root_path'] + if (scheme == 'http' and port == 80) or (scheme == 'https' and port == 443): + port = None + if port is not None: + return f"{scheme}://{host}:{port}{root}" + + return f"{scheme}://{host}{root}" + + def config(self) -> Configuration: return cast(Configuration, self.request.app.state.API.config)