diff --git a/public/games/games.js b/public/games/games.js index 1fe170a0e8356f6a2f2c642888b228937f45dc36..d919a2a8bdaed5e8d4bd87d24a200d555cee9e86 100644 --- a/public/games/games.js +++ b/public/games/games.js @@ -166,7 +166,9 @@ module.exports = { function fetchjson(url) { return new Promise((resolve, reject) => { - fetch(url, { mode: "no-cors" }) + const headers = new Headers(); + headers.append("Accept", "application/json"); + fetch(url, { mode: "no-cors", headers }) .then(r => r.json()) .then(r => resolve(r)) .catch(e => reject(e)); @@ -174,8 +176,10 @@ function fetchjson(url) { } function fetchtext(url) { + const headers = new Headers(); + headers.append("Accept", "text/html"); return new Promise((resolve, reject) => { - fetch(url, { mode: "no-cors" }) + fetch(url, { mode: "no-cors", headers }) .then(r => r.text()) .then(r => resolve(r)) .catch(e => reject(e)); diff --git a/public/main.js b/public/main.js index 9acdbd6e086051236263754a3d667960d62d34ea..4db5922f63c7a0dfe6a2b310d0f09363656b7942 100644 --- a/public/main.js +++ b/public/main.js @@ -435,7 +435,9 @@ module.exports = { function fetchjson(url) { return new Promise((resolve, reject) => { - fetch(url, { mode: "no-cors" }) + const headers = new Headers(); + headers.append("Accept", "application/json"); + fetch(url, { mode: "no-cors", headers }) .then(r => r.json()) .then(r => resolve(r)) .catch(e => reject(e)); @@ -443,8 +445,10 @@ function fetchjson(url) { } function fetchtext(url) { + const headers = new Headers(); + headers.append("Accept", "text/html"); return new Promise((resolve, reject) => { - fetch(url, { mode: "no-cors" }) + fetch(url, { mode: "no-cors", headers }) .then(r => r.text()) .then(r => resolve(r)) .catch(e => reject(e)); diff --git a/src/lib/fetch.js b/src/lib/fetch.js index 46a964f191e450ab7f69d79deb941dc2a93fae40..4ad85bdda6e414baffd6f8e041c11f4fcc8289f5 100644 --- a/src/lib/fetch.js +++ b/src/lib/fetch.js @@ -2,7 +2,9 @@ function fetchjson(url) { return new Promise((resolve, reject) => { - fetch(url, { mode: "no-cors" }) + const headers = new Headers(); + headers.append("Accept", "application/json"); + fetch(url, { mode: "no-cors", headers }) .then(r => r.json()) .then(r => resolve(r)) .catch(e => reject(e)); @@ -10,8 +12,10 @@ function fetchjson(url) { } function fetchtext(url) { + const headers = new Headers(); + headers.append("Accept", "text/html"); return new Promise((resolve, reject) => { - fetch(url, { mode: "no-cors" }) + fetch(url, { mode: "no-cors", headers }) .then(r => r.text()) .then(r => resolve(r)) .catch(e => reject(e));