From 13526aa1247bb3335bf4e08e61a0e446491cd62c Mon Sep 17 00:00:00 2001 From: surajp <85.suraj@gmail.com> Date: Fri, 11 Sep 2015 23:42:15 -0400 Subject: [PATCH] Changes to accomodate CORS support Added the ability to operate with no proxy, if the user chooses to do so, assuming they have CORS support enabled --- forcetk.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/forcetk.js b/forcetk.js index eb1d7f2..16ff1bb 100644 --- a/forcetk.js +++ b/forcetk.js @@ -57,10 +57,13 @@ if (forcetk.Client === undefined) { if (location.protocol === 'file:' || location.protocol === 'ms-appx:') { // In PhoneGap this.proxyUrl = null; - } else { + } else if (location.hostname.indexOf('force.com')>-1){ // In Visualforce - still need proxyUrl for Apex REST methods this.proxyUrl = location.protocol + "//" + location.hostname + "/services/proxy"; + } else { + //This means we are running locally, or on an external server, and we have CORS enabled (hopefully) + this.proxyUrl=null; } this.authzHeader = "Authorization"; } else {