soiz1 commited on
Commit
9269047
·
verified ·
1 Parent(s): c0f17bb

Update src/components/loader/tw-progress-monitor.js

Browse files
src/components/loader/tw-progress-monitor.js CHANGED
@@ -1,3 +1,5 @@
 
 
1
  let total = 0;
2
  let complete = 0;
3
 
@@ -50,6 +52,7 @@ const setState = newState => {
50
 
51
  export const fetchWithProgress = url => {
52
  setState(1);
 
53
  return new Promise((resolve, reject) => {
54
  // XMLHttpRequestの進行状況処理
55
  const xhr = new XMLHttpRequest();
@@ -61,13 +64,13 @@ export const fetchWithProgress = url => {
61
  }));
62
  };
63
  xhr.onloadend = () => setProgress(1);
64
- xhr.onerror = () => reject(new Error('[tw-progress-monitor] xhr failed with status' + xhr.status));
65
  xhr.onprogress = e => {
66
  if (e.lengthComputable) {
67
  setProgress(e.loaded / e.total);
68
  }
69
  };
70
- xhr.open('GET', url);
71
  xhr.send();
72
  });
73
  };
 
1
+ import CorsProxy from 'cors-proxy-library';
2
+
3
  let total = 0;
4
  let complete = 0;
5
 
 
52
 
53
  export const fetchWithProgress = url => {
54
  setState(1);
55
+ const proxyUrl = CorsProxy.getProxyUrl(url);
56
  return new Promise((resolve, reject) => {
57
  // XMLHttpRequestの進行状況処理
58
  const xhr = new XMLHttpRequest();
 
64
  }));
65
  };
66
  xhr.onloadend = () => setProgress(1);
67
+ xhr.onerror = () => reject(new Error('[tw-progress-monitor] xhr failed with status ' + xhr.status));
68
  xhr.onprogress = e => {
69
  if (e.lengthComputable) {
70
  setProgress(e.loaded / e.total);
71
  }
72
  };
73
+ xhr.open('GET', proxyUrl);
74
  xhr.send();
75
  });
76
  };