<?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: How to fix CORS issues when consuming AGS map services with JSAPI for ArcGIS? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-fix-cors-issues-when-consuming-ags-map/m-p/1048759#M72630</link>
    <description>&lt;P data-unlink="true"&gt;NOW I remember!&amp;nbsp; It was a self-inflicted wound.&amp;nbsp; For anyone else experiencing this, maybe you did what I did and this will help you too.&amp;nbsp; On the recommendation of&amp;nbsp; &lt;A href="https://enterprise.arcgis.com/en/server/latest/administer/linux/restricting-cross-domain-requests-to-arcgis-server.htm" target="_blank" rel="noopener"&gt;ESRI on this page&lt;/A&gt;, &amp;nbsp;I removed the wild card from Allowed Origins on my servicesDirectory settings in ArcGISSerer Admin and replaced it with my two GIS app server URL - this means that only this server is allowed to send Javascript requests to ArcGIS Server on my GIS data server.&amp;nbsp; It also means that the localhost machine (my development PC) cannot send javascript requests to ArcGIS server.&amp;nbsp; Once I added &lt;A href="https://localhost" target="_blank"&gt;https://localhost&lt;/A&gt;&amp;nbsp;to the Services Directory &amp;gt; AllowedOrigins it started working again.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Apr 2021 15:49:20 GMT</pubDate>
    <dc:creator>PLadd</dc:creator>
    <dc:date>2021-04-19T15:49:20Z</dc:date>
    <item>
      <title>How to fix CORS issues when consuming AGS map services with JSAPI for ArcGIS?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-fix-cors-issues-when-consuming-ags-map/m-p/249785#M23151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on my local machine with JSAPI in VS Code, and I'm getting&amp;nbsp;the following &lt;A href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" rel="nofollow noopener noreferrer" target="_blank"&gt;CORS&lt;/A&gt; related error thrown at me in Chrome Dev Tools:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Access to XMLHttpRequest at 'https//... my environment ..../MapServer?f=json' 
from origin 'http://localhost:8080' has been blocked by CORS policy: 
No 'Access-Control-Allow-Origin' header is present on the requested resource.‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've read enough about CORS to understand&amp;nbsp;its purpose, and that according to ESRI, ...&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;By default,&amp;nbsp;&lt;SPAN class=""&gt;ArcGIS Server&lt;/SPAN&gt; allows cross-domain requests so Javascript clients can invoke the server's services from any domain.... (&lt;A class="link-titled" href="http://enterprise.arcgis.com/en/server/latest/administer/linux/restricting-cross-domain-requests-to-arcgis-server.htm" title="http://enterprise.arcgis.com/en/server/latest/administer/linux/restricting-cross-domain-requests-to-arcgis-server.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Restrict cross-domain requests to ArcGIS Server—ArcGIS Server Administration (Linux) | ArcGIS Enterprise&lt;/A&gt;)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So I think no additional &lt;A href="https://enable-cors.org/server_iis7.html" rel="nofollow noopener noreferrer" target="_blank"&gt;tweaks to the web server &lt;/A&gt;are warranted. I've been able to&amp;nbsp;"work around" this by developing in a directory that's on the same Dev/Test box where my&amp;nbsp;map services are&amp;nbsp;running on. This works great.&amp;nbsp;Additionally,&amp;nbsp;I've reviewed 'Allowed Origins' in ArcGIS Server Administrator to make it meets my needs.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/441149_servicesdirectory.png" /&gt;&lt;/P&gt;&lt;P&gt;Are there other adjustments I could make that would allow me to still do all my work locally and hit AGS map services without CORS issues? I get the sense from reading various threads online that a lot of folks new to working with JSAPI may be running into this. But I haven't found the &lt;A _jive_internal="true" href="https://community.esri.com/community/developers/web-developers/arcgis-api-for-javascript/blog/2018/08/30/cors-and-the-arcgis-api-for-javascript-changes-coming-in-49" target="_blank"&gt;ESRI documentation&lt;/A&gt; tremendously illuminating.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:25:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-fix-cors-issues-when-consuming-ags-map/m-p/249785#M23151</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2021-12-11T12:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix CORS issues when consuming AGS map services with JSAPI for ArcGIS?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-fix-cors-issues-when-consuming-ags-map/m-p/1048749#M72628</link>
      <description>&lt;P&gt;Did you ever resolve this issue using localhost?&amp;nbsp; I just ran into this issue this morning (4/19/21) out of the blue - yet it worked fine for the previous 17 years.&amp;nbsp; &amp;nbsp;I can run a development sample on the same server (or any server) but I can't run it through localhost:44300.&amp;nbsp; And it's only the web page with the map services - all other pages load and work correctly.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 15:32:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-fix-cors-issues-when-consuming-ags-map/m-p/1048749#M72628</guid>
      <dc:creator>PLadd</dc:creator>
      <dc:date>2021-04-19T15:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix CORS issues when consuming AGS map services with JSAPI for ArcGIS?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-fix-cors-issues-when-consuming-ags-map/m-p/1048759#M72630</link>
      <description>&lt;P data-unlink="true"&gt;NOW I remember!&amp;nbsp; It was a self-inflicted wound.&amp;nbsp; For anyone else experiencing this, maybe you did what I did and this will help you too.&amp;nbsp; On the recommendation of&amp;nbsp; &lt;A href="https://enterprise.arcgis.com/en/server/latest/administer/linux/restricting-cross-domain-requests-to-arcgis-server.htm" target="_blank" rel="noopener"&gt;ESRI on this page&lt;/A&gt;, &amp;nbsp;I removed the wild card from Allowed Origins on my servicesDirectory settings in ArcGISSerer Admin and replaced it with my two GIS app server URL - this means that only this server is allowed to send Javascript requests to ArcGIS Server on my GIS data server.&amp;nbsp; It also means that the localhost machine (my development PC) cannot send javascript requests to ArcGIS server.&amp;nbsp; Once I added &lt;A href="https://localhost" target="_blank"&gt;https://localhost&lt;/A&gt;&amp;nbsp;to the Services Directory &amp;gt; AllowedOrigins it started working again.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 15:49:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-fix-cors-issues-when-consuming-ags-map/m-p/1048759#M72630</guid>
      <dc:creator>PLadd</dc:creator>
      <dc:date>2021-04-19T15:49:20Z</dc:date>
    </item>
  </channel>
</rss>

