From 91c7ea03ae763a1f2173e04288fac5622886451d Mon Sep 17 00:00:00 2001 From: Shlomo Zalman Heigh Date: Mon, 28 Sep 2020 05:56:47 -0400 Subject: [PATCH] Tus: add withCredentials, fix #2518 (#2544) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Renée Kooi --- packages/@uppy/tus/src/index.js | 8 +++++++- packages/@uppy/tus/types/index.d.ts | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/@uppy/tus/src/index.js b/packages/@uppy/tus/src/index.js index 30f9d79e0..1b651d997 100644 --- a/packages/@uppy/tus/src/index.js +++ b/packages/@uppy/tus/src/index.js @@ -70,7 +70,8 @@ module.exports = class Tus extends Plugin { resume: true, useFastRemoteRetry: true, limit: 0, - retryDelays: [0, 1000, 3000, 5000] + retryDelays: [0, 1000, 3000, 5000], + withCredentials: false } // merge default options with the ones set by user @@ -198,6 +199,11 @@ module.exports = class Tus extends Plugin { // the other in folder b. uploadOptions.fingerprint = getFingerprint(file) + uploadOptions.onBeforeRequest = (req) => { + const xhr = req.getUnderlyingObject() + xhr.withCredentials = !!opts.withCredentials + } + uploadOptions.onError = (err) => { this.uppy.log(err) diff --git a/packages/@uppy/tus/types/index.d.ts b/packages/@uppy/tus/types/index.d.ts index f920f1b8e..a392f236f 100644 --- a/packages/@uppy/tus/types/index.d.ts +++ b/packages/@uppy/tus/types/index.d.ts @@ -18,6 +18,7 @@ declare module Tus { autoRetry?: boolean limit?: number useFastRemoteRetry?: boolean + withCredentials?: boolean } }