fixing(gateway)

This commit is contained in:
2025-08-14 00:35:51 +02:00
parent b67d75543e
commit d0232c23a0
11 changed files with 50 additions and 26 deletions
@@ -20,7 +20,7 @@ class PingService(private val baseUrl: String = "http://localhost:8080") {
}
suspend fun ping(): Result<PingResponse> = try {
val response = client.get("$baseUrl/ping-service/ping").body<PingResponse>()
val response = client.get("$baseUrl/api/ping/ping").body<PingResponse>()
Result.success(response)
} catch (e: Exception) {
Result.failure(e)
@@ -20,7 +20,7 @@ fun App(baseUrl: String = "http://localhost:8080") {
@Composable
fun PingScreen(baseUrl: String) {
val pingComponent = remember { PingTestComponent() }
val pingComponent = remember { PingTestComponent(baseUrl) }
var pingState by remember { mutableStateOf(pingComponent.state) }
LaunchedEffect(pingComponent) {
@@ -11,8 +11,8 @@ data class PingTestState(
val isConnected: Boolean = false
)
class PingTestComponent {
private val pingService = PingService()
class PingTestComponent(baseUrl: String = "http://localhost:8080") {
private val pingService = PingService(baseUrl)
private val scope = CoroutineScope(Dispatchers.Main + SupervisorJob())
var state: PingTestState = PingTestState()
@@ -15,7 +15,11 @@ fun main() {
@Composable
fun MeldestelleWebApp() {
val pingComponent = remember { PingTestComponent() }
// Get baseUrl from a window location or use default
val baseUrl = remember {
js("window.location.origin").toString().ifEmpty { "http://localhost:8080" }
}
val pingComponent = remember { PingTestComponent(baseUrl) }
var pingState by remember { mutableStateOf(pingComponent.state) }
LaunchedEffect(pingComponent) {