Is there a way to override a `defaultRequest`s `ho...
# ktor
s
Is there a way to override a `defaultRequest`s
host
? Doing this is not working:
Copy code
val httpClient = HttpClient(Android) {
        defaultRequest {
            contentType(ContentType.Application.Json)
            url {
                host = currentBuildEnvironment.defaultEndpoint
                protocol = URLProtocol.HTTPS
            }
        }
    }

//elsewhere..
fun makeRequest() = <http://httpClient.post|httpClient.post> {
    url {
        encodedPath = "/endpoint"
        host = currentBuildEnvironment.otherEndpoint
    }
    body = //etc
}
It's using
defaultEndpoint
instead of
otherEndpoint
. Am I missing something here?
I could make a separate httpClient that uses this other host but it's the only function I have that needs this separate host endpoint, so I would prefer to just override it if I can
for now i've just made a default url builder that I can override the host with and replaced its usage in my api call functions, but would still like to just override defaultRequest host if I can
👀 1
o
Hello, I've recently asked the same question. I'm sorry you didn't get any answer to that :(