From 234c921842fbf5a3b20acb443ddc711a3ca2937e Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 19 Jan 2020 22:46:42 +0100 Subject: Add support for authenticated CORS requests --- .../src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'kvision-modules/kvision-remote') 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 58ba7368..eca6dbb0 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 @@ -29,7 +29,6 @@ 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 /** @@ -101,6 +100,9 @@ open class CallAgent { reject(Exception(message)) } } + this.xhrFields = obj { + this.withCredentials = true + } }) } } @@ -111,7 +113,7 @@ open class CallAgent { * @param data data to be sent * @param method a HTTP method * @param contentType a content type of the request - * @param beforeSend a content type of the request + * @param beforeSend a function to set request parameters * @return a promise of the result */ @Suppress("UnsafeCastFromDynamic", "ComplexMethod") @@ -148,6 +150,9 @@ open class CallAgent { } } this.beforeSend = beforeSend + this.xhrFields = obj { + this.withCredentials = true + } }) } } -- cgit