Skip to content

Commit bf0feee

Browse files
committed
XHRSettings.withCredentials is a new boolean property that controls the withCredentials setting of the XHR Request made by the Loader. It indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies, authorization headers or TLS client certificates. You can set this on a per-file basis, or global in the Game Config.
1 parent 5d962c6 commit bf0feee

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/loader/XHRSettings.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@
1515
* @param {string} [user=''] - Optional username for the XHR request.
1616
* @param {string} [password=''] - Optional password for the XHR request.
1717
* @param {integer} [timeout=0] - Optional XHR timeout value.
18+
* @param {boolean} [withCredentials=false] - Optional XHR withCredentials value.
1819
*
1920
* @return {Phaser.Types.Loader.XHRSettingsObject} The XHRSettings object as used by the Loader.
2021
*/
21-
var XHRSettings = function (responseType, async, user, password, timeout)
22+
var XHRSettings = function (responseType, async, user, password, timeout, withCredentials)
2223
{
2324
if (responseType === undefined) { responseType = ''; }
2425
if (async === undefined) { async = true; }
2526
if (user === undefined) { user = ''; }
2627
if (password === undefined) { password = ''; }
2728
if (timeout === undefined) { timeout = 0; }
29+
if (withCredentials === undefined) { withCredentials = false; }
2830

2931
// Before sending a request, set the xhr.responseType to "text",
3032
// "arraybuffer", "blob", or "document", depending on your data needs.
@@ -50,7 +52,10 @@ var XHRSettings = function (responseType, async, user, password, timeout)
5052
requestedWith: false,
5153

5254
// overrideMimeType
53-
overrideMimeType: undefined
55+
overrideMimeType: undefined,
56+
57+
// withCredentials
58+
withCredentials: withCredentials
5459

5560
};
5661
};

src/loader/typedefs/XHRSettingsObject.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
* @property {(string|undefined)} [headerValue] - This value is used to populate the XHR `setRequestHeader` and is undefined by default.
1212
* @property {(string|undefined)} [requestedWith] - This value is used to populate the XHR `setRequestHeader` and is undefined by default.
1313
* @property {(string|undefined)} [overrideMimeType] - Provide a custom mime-type to use instead of the default.
14+
* @property {boolean} [withCredentials=false] - The withCredentials property indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies, authorization headers or TLS client certificates. Setting withCredentials has no effect on same-site requests.
1415
*/

0 commit comments

Comments
 (0)