fix(auth): use ServerEndpoint in relogin() to fix HTTPS/proxy 404 (#812)

relogin() hardcoded http://host:port, dropping scheme + path prefix. Use
endpointForBuild().resolve(...) like connectBasicAuth(). Fixes #802.

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
M57andM57 authored and GitHub committed 2026-08-04 18:35:08 +03:00
1 parent 6e1ea494c5
commit b28440d659
1 file changed
+3 -5
@@ -2887,9 +2887,7 @@ class ChatViewModel(
onResult: (Boolean, String?) -> Unit,
) {
viewModelScope.launch(Dispatchers.IO) {
val host = AuthManager.getHost()
val port = AuthManager.getPort()
val baseUrl = "http://$host:$port"
val endpoint = AuthManager.endpointForBuild()
val jsonMediaType = "application/json; charset=utf-8".toMediaType()
val jsonBody =
JSONObject()
@@ -2910,7 +2908,7 @@ class ChatViewModel(
val loginReq =
Request
.Builder()
.url("$baseUrl/auth/password-login")
.url(endpoint.resolve("auth/password-login").toString())
.header("Content-Type", "application/json")
.post(jsonBody.toRequestBody(jsonMediaType))
.build()
@@ -2939,7 +2937,7 @@ class ChatViewModel(
val ticketReq =
Request
.Builder()
.url("$baseUrl/api/auth/ws-ticket")
.url(endpoint.resolve("api/auth/ws-ticket").toString())
.post("{}".toRequestBody(jsonMediaType))
.build()
ticketClient.newCall(ticketReq).execute().use { ticketResp ->