X-Git-Url: https://git.auder.net/img/rock_paper_scissors_lizard_spock.gif?a=blobdiff_plain;f=client%2Fsrc%2Futils%2Fajax.js;h=01ea84935f132ebf7713cbf4f7a242eea3ffe791;hb=e64c6f67185b45b3b1205069532362c1bf9680db;hp=1d181fa2a2837105571460480779b4ef592a7a87;hpb=deca03e8aeb7cac9c19b0d43b4642b27299695b5;p=vchess.git diff --git a/client/src/utils/ajax.js b/client/src/utils/ajax.js index 1d181fa2..01ea8493 100644 --- a/client/src/utils/ajax.js +++ b/client/src/utils/ajax.js @@ -1,5 +1,8 @@ import params from "../parameters"; //for server URL +// TODO: replace by fetch API ? +// https://www.sitepoint.com/xmlhttprequest-vs-the-fetch-api-whats-best-for-ajax-in-2019/ + // From JSON (encoded string values!) to "arg1=...&arg2=..." function toQueryString(data) { @@ -48,7 +51,8 @@ export function ajax(url, method, data, success, error) xhr.open(method, params.serverUrl + url, true); xhr.setRequestHeader('X-Requested-With', "XMLHttpRequest"); // Next line to allow cross-domain cookies in dev mode (TODO: if...) - xhr.withCredentials = true; + if (params.cors) + xhr.withCredentials = true; if (["POST","PUT"].includes(method)) { xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");