aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/request.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-07-17 14:27:57 -0400
committerGitHub <noreply@github.com>2020-07-17 14:27:57 -0400
commitf9c76efea00ff62021119c4d0fcf414e8988be1d (patch)
tree47007976a68c4fc3ad231abf03615e1be04f782e /ext/bg/js/request.js
parentfc31e6fab54cdc3be42d4f3867941d3a907b6b88 (diff)
Fix Anki CORS requests (#666)
Diffstat (limited to 'ext/bg/js/request.js')
-rw-r--r--ext/bg/js/request.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/bg/js/request.js b/ext/bg/js/request.js
index d1c6ed4e..4a455850 100644
--- a/ext/bg/js/request.js
+++ b/ext/bg/js/request.js
@@ -16,10 +16,10 @@
*/
-async function requestText(url, method, data) {
+async function requestText(url, method, data, cors=false) {
const response = await fetch(url, {
method,
- mode: 'no-cors',
+ mode: (cors ? 'cors' : 'no-cors'),
cache: 'default',
credentials: 'omit',
redirect: 'follow',
@@ -29,10 +29,10 @@ async function requestText(url, method, data) {
return await response.text();
}
-async function requestJson(url, method, data) {
+async function requestJson(url, method, data, cors=false) {
const response = await fetch(url, {
method,
- mode: 'no-cors',
+ mode: (cors ? 'cors' : 'no-cors'),
cache: 'default',
credentials: 'omit',
redirect: 'follow',