Ktorfit
Ktorfit copied to clipboard
When using custom HTTP client, HttpClient's urlBuild does not work
Ktorfit version
1.11.0
What happened and how can we reproduce this issue?
Set the baseURL of ktorfit to empty, and use urlbuild to dynamically return the baseURL when building an HTTP client
val client=HttpClient {
defaultRequest {
if(headers["Content-Type"].isNullOrEmpty()){
header("Content-Type","application/json")
}
url{
val prefer: AppPreferences =get()
val url=runBlocking { prefer.host() }
//this url should https://api.github.com
url
}
}
install(Logging) {
logger = object: Logger {
override fun log(message: String) {
Napier.v("HTTP Client", null, message)
}
}
level = LogLevel.BODY
}
install(HttpCookies)
install(ContentNegotiation) {
json(json= get())
}
}.also { Napier.base(DebugAntilog()) }
val kf=ktorfit {
baseUrl("",false)
httpClient(client)
converterFactories(
CallConverterFactory()
)
}
What did you expect to happen?
When I access api/v1/auth/signin, I should access https://api.github.com/api/v1/auth/signin ,
And the actual situation is http://localhost/api/v1/auth/signin
Is there anything else we need to know about?
No response