diff --git a/package.json b/package.json index 9b505d5..99da191 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "colyseus.js", - "version": "0.15.22", + "version": "0.15.23", "description": "Colyseus Multiplayer SDK for JavaScript/TypeScript", "author": "Endel Dreyer", "license": "MIT", diff --git a/src/HTTP.ts b/src/HTTP.ts index daa75a7..5861b3f 100644 --- a/src/HTTP.ts +++ b/src/HTTP.ts @@ -45,8 +45,15 @@ export class HTTP { options.headers['Authorization'] = `Bearer ${this.authToken}`; } - // always include credentials - options.withCredentials = true; + if (typeof (cc) !== 'undefined' && cc.sys && cc.sys.isNative) { + // + // Workaround for Cocos Creator on Native platform + // "Cannot set property withCredentials of # which has only a getter" + // + } else { + // always include credentials + options.withCredentials = true; + } return options; } diff --git a/typings/cocos-creator.d.ts b/typings/cocos-creator.d.ts index 7082fb3..d811a3f 100644 --- a/typings/cocos-creator.d.ts +++ b/typings/cocos-creator.d.ts @@ -9,5 +9,8 @@ declare module cc { export interface Isys { /** cc.sys.localStorage is a local storage component. */ localStorage: Storage; + + /** Is native ? This is set to be true in jsb auto. */ + isNative: boolean; } }