<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Option to Disable CORS or Use withCredentials in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408620#M37638</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Something like option 2 from american_data would be great. I have a need to consume services from a separate domain that requires a user PKI cert. I'd like to be able to specify 'withCredentials = true' so that the services could be used in a CORS fashion.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Jul 2013 13:39:43 GMT</pubDate>
    <dc:creator>ChrisKeefer</dc:creator>
    <dc:date>2013-07-02T13:39:43Z</dc:date>
    <item>
      <title>Option to Disable CORS or Use withCredentials</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408617#M37635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Currently we cannot use the last 3 versions of ArcGIS for Javascript because authentication cookies are not sent with CORS requests.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a couple of ideas to request as a solution:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Give us a global configuration option to enable/disable CORS&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
esri.config.defaults.io.enableCors = true | false;
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Allow us to include credentials in request via esri.setRequestPreCallback&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
esri.setRequestPreCallback(function (ioArgs) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; ioArgs.withCredentials = (shouldUseCredentials(ioArgs.url) === true);
&amp;nbsp;&amp;nbsp;&amp;nbsp; return ioArgs;
});
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If something like this already present and I missed it, my mistake.&amp;nbsp; Please lead me in the right direction.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 23:15:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408617#M37635</guid>
      <dc:creator>AmericanData</dc:creator>
      <dc:date>2013-07-01T23:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: Option to Disable CORS or Use withCredentials</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408618#M37636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried what is suggested on the &lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/en/javascript/jshelp/ags_secureservices.html"&gt;&lt;SPAN style="font-style:italic;"&gt;Working with Secure Resources&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; page?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 23:23:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408618#M37636</guid>
      <dc:creator>JeffJacobson</dc:creator>
      <dc:date>2013-07-01T23:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Option to Disable CORS or Use withCredentials</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408619#M37637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;&lt;SPAN&gt;Authentication in general is not the problem though you are on the right track.&amp;nbsp; We do use a proxy.&amp;nbsp; But we use subdomaining to allow more requests to our proxy than the standard 2-request limit most browsers procure.&amp;nbsp; (see &lt;A href="&amp;lt;/span&amp;gt;&amp;lt;a" target="_blank"&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Using multiple subdomains with a tiled service layer&lt;/SPAN&gt;&lt;SPAN&gt;, an ArcGIS for Silverlight example).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Our proxy uses its own authentication.&amp;nbsp; It's a custom proxy, not the simple one from ESRI.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If no ideas generate, that's fine.&amp;nbsp; I'll manipulate the API in-house.&amp;nbsp; Just making a request because it sure would be nice to have.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 00:14:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408619#M37637</guid>
      <dc:creator>AmericanData</dc:creator>
      <dc:date>2013-07-02T00:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Option to Disable CORS or Use withCredentials</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408620#M37638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Something like option 2 from american_data would be great. I have a need to consume services from a separate domain that requires a user PKI cert. I'd like to be able to specify 'withCredentials = true' so that the services could be used in a CORS fashion.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 13:39:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408620#M37638</guid>
      <dc:creator>ChrisKeefer</dc:creator>
      <dc:date>2013-07-02T13:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: Option to Disable CORS or Use withCredentials</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408621#M37639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Solved my problem by delving into the API code.&amp;nbsp; (Thank you so much for being transparent, ESRI!)&amp;nbsp; Was actually quite simple once you read through it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It would still be nice to have the option.&amp;nbsp; But as long as I can override/wrap functions, I'm good.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would reveal my solution.&amp;nbsp; But I don't think it's a good idea to expose a hack to the mass.&amp;nbsp; Would be better to let ESRI add the functionality, in my opinion.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 14:59:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408621#M37639</guid>
      <dc:creator>AmericanData</dc:creator>
      <dc:date>2013-07-02T14:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Option to Disable CORS or Use withCredentials</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408622#M37640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Solved my problem by delving into the API code.&amp;nbsp; (Thank you so much for being transparent, ESRI!)&amp;nbsp; Was actually quite simple once you read through it.&lt;BR /&gt;&lt;BR /&gt;It would still be nice to have the option.&amp;nbsp; But as long as I can override/wrap functions, I'm good.&lt;BR /&gt;&lt;BR /&gt;I would reveal my solution.&amp;nbsp; But I don't think it's a good idea to expose a hack to the mass.&amp;nbsp; Would be better to let ESRI add the functionality, in my opinion.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd be very interested to see what you ended up doing. Would you mind PM-ing me if you don't want to expose the hack to the masses?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 15:07:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408622#M37640</guid>
      <dc:creator>ChrisKeefer</dc:creator>
      <dc:date>2013-07-02T15:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Option to Disable CORS or Use withCredentials</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408623#M37641</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My solution was for a specific scenario. Decided to investigate into a more universal solution.&amp;nbsp; Here's one to turn on withCredentials in general.&amp;nbsp; This uses DOJO directly, thereby being useful beyond ArcGIS for JS.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Be sure to require "dojo/request/xhr" somewhere and put this in your addOnLoad function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!dojo._xhr) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo._xhr = dojo.xhr;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.xhr = function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var args = arguments[1];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; args["withCredentials"] = true;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arguments[1] = args;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (e) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log(e);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return dojo._xhr(arguments[0], arguments[1]);
&amp;nbsp;&amp;nbsp;&amp;nbsp; };
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This works for DOJO 1.8.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would recommend checking the url before enabling withCredentials.&amp;nbsp; The url is in arg.url.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See &lt;/SPAN&gt;&lt;A href="http://dojotoolkit.org/reference-guide/1.9/dojo/request/xhr.html" rel="nofollow noopener noreferrer" target="_blank"&gt;dojo/request/xhr&lt;/A&gt;&lt;SPAN&gt; for more details on the xhr.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;btw deriven = american_data &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:34:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408623#M37641</guid>
      <dc:creator>DerivenC</dc:creator>
      <dc:date>2021-12-11T18:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Option to Disable CORS or Use withCredentials</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408624#M37642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;deriven,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your reply! I will def make use of this! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I still hope ESRI includes something in a future release.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2013 14:00:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408624#M37642</guid>
      <dc:creator>ChrisKeefer</dc:creator>
      <dc:date>2013-07-09T14:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Option to Disable CORS or Use withCredentials</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408625#M37643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We have been experiencing the same problems.&amp;nbsp; CORS is only now becoming widely adopted and the ArcGIS JavaScript API is doing too much to automatically enable it or default to require a proxy page.&amp;nbsp; This has made our initial understanding and troubleshooting of these HTTP Authentication issues confusing.&amp;nbsp; We should be able to clearly and easily override these automatic behaviors in our API configurations.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I like the concept of Benjamin's solution #1 from post #1 if it can be implemented.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The dojo XHR "withCredentials" approach from post #7 seems to work and makes complete sense in the context of CORS, but we are a little concerned about security implications we may not have considered.&amp;nbsp; I suppose since XHR "withCredentials" cannot be used in conjunction with 'Access-Control-Allow-Origin: "*"' it may be safe.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In addition to the implementation of solution #1 from post #1, I would like to see the behavior of post #7 added to the API via a boolean switch in esri.io.defaults.config (for example "esri.config.defaults.io.corsWithCredentials = true" or "esri.config.defaults.io.xhrWithCredentials = true") and documented in the SDK, including any potential security concerns.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jul 2013 15:18:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/option-to-disable-cors-or-use-withcredentials/m-p/408625#M37643</guid>
      <dc:creator>TerrySherman</dc:creator>
      <dc:date>2013-07-10T15:18:04Z</dc:date>
    </item>
  </channel>
</rss>

