Kaynağa Gözat

Merge pull request #874 from tuoxiansp/master

add withCredentials option
Renée Kooi 6 yıl önce
ebeveyn
işleme
67d76e3f36
2 değiştirilmiş dosya ile 9 ekleme ve 0 silme
  1. 5 0
      src/plugins/XHRUpload.js
  2. 4 0
      website/src/docs/xhrupload.md

+ 5 - 0
src/plugins/XHRUpload.js

@@ -49,6 +49,7 @@ module.exports = class XHRUpload extends Plugin {
       locale: defaultLocale,
       timeout: 30 * 1000,
       limit: 0,
+      withCredentials: false,
       /**
        * @typedef respObj
        * @property {string} responseText
@@ -202,6 +203,8 @@ module.exports = class XHRUpload extends Plugin {
       const xhr = new XMLHttpRequest()
       const id = cuid()
 
+      xhr.withCredentials = opts.withCredentials
+
       xhr.upload.addEventListener('loadstart', (ev) => {
         this.uppy.log(`[XHRUpload] ${id} started`)
         // Begin checking for timeouts when loading starts.
@@ -362,6 +365,8 @@ module.exports = class XHRUpload extends Plugin {
 
       const xhr = new XMLHttpRequest()
 
+      xhr.withCredentials = this.opts.withCredentials
+
       const timer = this.createProgressTimeout(this.opts.timeout, (error) => {
         xhr.abort()
         emitError(error)

+ 4 - 0
website/src/docs/xhrupload.md

@@ -153,6 +153,10 @@ The default is 30 seconds.
 
 Limit the amount of uploads going on at the same time. Passing `0` means no limit.
 
+### `withCredentials: false`
+
+Indicates whether or not cross-site Access-Control requests should be made using credentials.
+
 ### `locale: {}`
 
 Localize text that is shown to the user.