فهرست منبع

added cors mode

Gildas 7 سال پیش
والد
کامیت
5e4c5ab006
2فایلهای تغییر یافته به همراه3 افزوده شده و 2 حذف شده
  1. 1 0
      lib/fetch/bg/fetch.js
  2. 2 2
      lib/fetch/content/fetch.js

+ 1 - 0
lib/fetch/bg/fetch.js

@@ -65,6 +65,7 @@
 	async function superFetch(url) {
 		return new Promise((resolve, reject) => {
 			const xhrRequest = new XMLHttpRequest();
+			xhrRequest.withCredentials = true;
 			xhrRequest.responseType = "arraybuffer";
 			xhrRequest.onerror = event => reject(new Error(event.details));
 			xhrRequest.onreadystatechange = () => {

+ 2 - 2
lib/fetch/content/fetch.js

@@ -25,7 +25,7 @@ this.superFetch = this.superFetch || (() => {
 	const superFetch = {
 		fetch: async url => {
 			try {
-				return await fetch(url);
+				return await fetch(url, { mode: "cors" });
 			} catch (error) {
 				const responseFetch = await sendMessage({ method: "fetch", url });
 				return {
@@ -40,7 +40,7 @@ this.superFetch = this.superFetch || (() => {
 	};
 	if (typeof XPCNativeWrapper != "undefined" && typeof wrappedJSObject != "undefined") {
 		superFetch.hostFetch = async url => {
-			return await XPCNativeWrapper(wrappedJSObject.fetch)(url);
+			return await XPCNativeWrapper(wrappedJSObject.fetch)(url, { mode: "cors" });
 		};
 	}
 	return superFetch;