From 0a8bd0df934dbef6c77b6f7ac51af4e53f916f3e Mon Sep 17 00:00:00 2001 From: Minh Cung Date: Thu, 8 Aug 2024 12:27:10 +1000 Subject: [PATCH 1/2] fix credentials bug --- src/Typesense/ApiCall.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Typesense/ApiCall.ts b/src/Typesense/ApiCall.ts index c96b33c8..70a05a8e 100644 --- a/src/Typesense/ApiCall.ts +++ b/src/Typesense/ApiCall.ts @@ -205,6 +205,14 @@ export default class ApiCall { ], }; + // credential field is set by default (https://github.com/axios/axios/pull/6505) + // which is causing issue when running cloudflare worker (// https://github.com/cloudflare/workers-sdk/issues/2514) + // We explicitly set "credentials" as undefined if it's not supported + const isCredentialsSupported = "credentials" in Request.prototype; + if (!isCredentialsSupported) { + requestOptions.credentials = undefined; + } + if (skipConnectionTimeout !== true) { requestOptions.timeout = this.connectionTimeoutSeconds * 1000; } From c9618f5935cee2551b53101494bd1c8a835e8426 Mon Sep 17 00:00:00 2001 From: Minh Cung Date: Thu, 8 Aug 2024 12:29:35 +1000 Subject: [PATCH 2/2] Update ApiCall.ts --- src/Typesense/ApiCall.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Typesense/ApiCall.ts b/src/Typesense/ApiCall.ts index 70a05a8e..a830eeb8 100644 --- a/src/Typesense/ApiCall.ts +++ b/src/Typesense/ApiCall.ts @@ -206,11 +206,11 @@ export default class ApiCall { }; // credential field is set by default (https://github.com/axios/axios/pull/6505) - // which is causing issue when running cloudflare worker (// https://github.com/cloudflare/workers-sdk/issues/2514) + // which is causing issue when running cloudflare worker (https://github.com/cloudflare/workers-sdk/issues/2514) // We explicitly set "credentials" as undefined if it's not supported const isCredentialsSupported = "credentials" in Request.prototype; if (!isCredentialsSupported) { - requestOptions.credentials = undefined; + requestOptions.withCredentials = undefined; } if (skipConnectionTimeout !== true) {