Explorar el Código

Tus: add withCredentials, fix #2518 (#2544)

Co-authored-by: Renée Kooi <renee@kooi.me>
Shlomo Zalman Heigh hace 4 años
padre
commit
91c7ea03ae
Se han modificado 2 ficheros con 8 adiciones y 1 borrados
  1. 7 1
      packages/@uppy/tus/src/index.js
  2. 1 0
      packages/@uppy/tus/types/index.d.ts

+ 7 - 1
packages/@uppy/tus/src/index.js

@@ -70,7 +70,8 @@ module.exports = class Tus extends Plugin {
       resume: true,
       resume: true,
       useFastRemoteRetry: true,
       useFastRemoteRetry: true,
       limit: 0,
       limit: 0,
-      retryDelays: [0, 1000, 3000, 5000]
+      retryDelays: [0, 1000, 3000, 5000],
+      withCredentials: false
     }
     }
 
 
     // merge default options with the ones set by user
     // merge default options with the ones set by user
@@ -198,6 +199,11 @@ module.exports = class Tus extends Plugin {
       // the other in folder b.
       // the other in folder b.
       uploadOptions.fingerprint = getFingerprint(file)
       uploadOptions.fingerprint = getFingerprint(file)
 
 
+      uploadOptions.onBeforeRequest = (req) => {
+        const xhr = req.getUnderlyingObject()
+        xhr.withCredentials = !!opts.withCredentials
+      }
+
       uploadOptions.onError = (err) => {
       uploadOptions.onError = (err) => {
         this.uppy.log(err)
         this.uppy.log(err)
 
 

+ 1 - 0
packages/@uppy/tus/types/index.d.ts

@@ -18,6 +18,7 @@ declare module Tus {
     autoRetry?: boolean
     autoRetry?: boolean
     limit?: number
     limit?: number
     useFastRemoteRetry?: boolean
     useFastRemoteRetry?: boolean
+    withCredentials?: boolean
   }
   }
 }
 }