From 7c1e742dcb0bb6708a7eaa015e8a16efea4fee8b Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 18 Jan 2020 22:44:57 +0100 Subject: Add an option for an external URL prefix of remote KVision services --- .../src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'kvision-modules/kvision-remote/src/main') diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt index 0a56465d..58ba7368 100644 --- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt +++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt @@ -23,9 +23,11 @@ package pl.treksoft.kvision.remote import kotlinx.serialization.ImplicitReflectionSerializer import kotlinx.serialization.stringify +import org.w3c.dom.get import pl.treksoft.jquery.JQueryAjaxSettings import pl.treksoft.jquery.JQueryXHR import pl.treksoft.jquery.jQuery +import kotlin.browser.window import kotlin.js.Promise import kotlin.js.undefined import kotlin.js.JSON as NativeJSON @@ -40,6 +42,8 @@ const val HTTP_UNAUTHORIZED = 401 */ open class CallAgent { + private val kvUrlPrefix = window["kv_remote_url_prefix"] + private val urlPrefix: String = if (kvUrlPrefix != undefined) kvUrlPrefix else "" private var counter = 1 /** @@ -63,7 +67,7 @@ open class CallAgent { JSON.plain.stringify(jsonRpcRequest) } return Promise { resolve, reject -> - jQuery.ajax(url, obj { + jQuery.ajax(urlPrefix + url, obj { this.contentType = "application/json" this.data = jsonData this.method = method.name -- cgit