<?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: ArcGIS JS API v 4.x Cors in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/717798#M66664</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;Abdelrahman,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;You may need to add a trusted server, e.g.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request" title="https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request"&gt;config | ArcGIS API for JavaScript 4.14&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="" style="color: #5c2699; font-weight: 300;"&gt;require&lt;/SPAN&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8; font-weight: 300;"&gt;([&lt;/SPAN&gt;&lt;SPAN class="" style="color: #c41a16; font-weight: 300;"&gt;"esri/config"&lt;/SPAN&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8; font-weight: 300;"&gt;], &lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959; font-weight: 300;"&gt;&lt;SPAN class="" style="color: #aa0d91; font-weight: bold;"&gt;function&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #5c2699;"&gt;esriConfig&lt;/SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8; font-weight: 300;"&gt;{ esriConfig.request.trustedServers.push(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #c41a16; font-weight: 300;"&gt;"[&amp;lt;protocol&amp;gt;//]&amp;lt;hostname&amp;gt;.&amp;lt;domain&amp;gt;[:&amp;lt;port&amp;gt;]"&lt;/SPAN&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8; font-weight: 300;"&gt;); });&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; background-color: #ffffff; font-weight: 400;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; background-color: #ffffff; font-weight: 400;"&gt;Rhys&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 05 Apr 2020 08:17:22 GMT</pubDate>
    <dc:creator>Rhys-Donoghue</dc:creator>
    <dc:date>2020-04-05T08:17:22Z</dc:date>
    <item>
      <title>ArcGIS JS API v 4.x Cors</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/717797#M66663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have a cached map service, whenever I try to add it to the map using ArcGIS JS API v 3.x "ArcGISTiledMapServiceLayer" it works fine.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But whenever I try to add it to the map, using ArcGIS JS API v 4.x "TileLayer" I get this error&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 13px;"&gt;"Access to fetch at '&lt;SPAN style="text-decoration: underline;"&gt;Service URL&lt;/SPAN&gt;' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could anyone please assist me with that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Abdelrahman.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2020 13:45:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/717797#M66663</guid>
      <dc:creator>AbdelrahmanAbdelrazek</dc:creator>
      <dc:date>2020-02-14T13:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JS API v 4.x Cors</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/717798#M66664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;Abdelrahman,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;You may need to add a trusted server, e.g.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request" title="https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request"&gt;config | ArcGIS API for JavaScript 4.14&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="" style="color: #5c2699; font-weight: 300;"&gt;require&lt;/SPAN&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8; font-weight: 300;"&gt;([&lt;/SPAN&gt;&lt;SPAN class="" style="color: #c41a16; font-weight: 300;"&gt;"esri/config"&lt;/SPAN&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8; font-weight: 300;"&gt;], &lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959; font-weight: 300;"&gt;&lt;SPAN class="" style="color: #aa0d91; font-weight: bold;"&gt;function&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #5c2699;"&gt;esriConfig&lt;/SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8; font-weight: 300;"&gt;{ esriConfig.request.trustedServers.push(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #c41a16; font-weight: 300;"&gt;"[&amp;lt;protocol&amp;gt;//]&amp;lt;hostname&amp;gt;.&amp;lt;domain&amp;gt;[:&amp;lt;port&amp;gt;]"&lt;/SPAN&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8; font-weight: 300;"&gt;); });&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; background-color: #ffffff; font-weight: 400;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; background-color: #ffffff; font-weight: 400;"&gt;Rhys&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Apr 2020 08:17:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/717798#M66664</guid>
      <dc:creator>Rhys-Donoghue</dc:creator>
      <dc:date>2020-04-05T08:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JS API v 4.x Cors</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/717799#M66665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rhys for your response, I did try that.&lt;/P&gt;&lt;P&gt;But unfortunately still getting the same error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2020 12:07:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/717799#M66665</guid>
      <dc:creator>AbdelrahmanAbdelrazek</dc:creator>
      <dc:date>2020-04-06T12:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JS API v 4.x Cors</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/717800#M66666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This acatually worked for me when I switched to 4.15&lt;/P&gt;&lt;P&gt;Thanks &lt;A href="https://community.esri.com/migrated-users/252042"&gt;Rhys Donoghue&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2020 23:08:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/717800#M66666</guid>
      <dc:creator>AbdelrahmanAbdelrazek</dc:creator>
      <dc:date>2020-05-04T23:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JS API v 4.x Cors</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/717801#M66667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmm, should have worked for 4.14 but wouldn't surprise me if there was a bug.&amp;nbsp; 4.15 fixed a few bugs I was having with my app.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2020 03:07:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/717801#M66667</guid>
      <dc:creator>Rhys-Donoghue</dc:creator>
      <dc:date>2020-05-05T03:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JS API v 4.x Cors</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/717802#M66668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I'm getting the same CORS error.&amp;nbsp; I've added the trusted server with no effect.&amp;nbsp; Can you provide an example of the format?&amp;nbsp; Do you have to provide the port? I'm using 4.16.&amp;nbsp; I used to use&amp;nbsp;esriConfig.defaults.io.corsEnabledServers.push on the 3.x api and it seemed like it actually worked.&amp;nbsp; But trustedServers.push doesn't seem to ever work.&amp;nbsp; Does it do the same thing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2020 15:14:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/717802#M66668</guid>
      <dc:creator>NilsBabel1</dc:creator>
      <dc:date>2020-11-05T15:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JS API v 4.x Cors</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/1329582#M82239</link>
      <description>&lt;P&gt;Hi Rhys,&lt;/P&gt;&lt;P&gt;I am also trying to pass api-key in header using esriConfig.request.interceptors as well as esriConfig.request.trustedServers, however, it doesn't return the geojson results as I am able to extract through postman.&amp;nbsp; Any crue what is causing CORS error through this request method?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    esriConfig.request.trustedServers.push(this.base_url);
    esriConfig.request.interceptors.push({
      urls: geojson_url,
      before: function (params: any) {
        params.requestOptions.headers = {
          'x-api-key': this.x_api_key,
          'Access-Control-Allow-Origin': this.base_url,
        };
      },    
      after: function(response) {
        if (!response.ssl) {
          response.ssl = true;
        }
        const geojsonLayer = new GeoJSONLayer({
          title: 'Forecast Kind',
          url: response.data, 
          popupTemplate: template_forecast_kind,
          visible: false,
          outFields:["*"] 
        });
      },
      headers: {
        'x-api-key': this.x_api_key,
        'Access-Control-Allow-Origin': '*',
      },
    });
    &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error shows:&lt;/P&gt;&lt;P&gt;Access to fetch at 'https://.....com/sites/current_forecast_status' from origin '&lt;A href="http://localhost:4200" target="_blank" rel="noopener"&gt;http://localhost:4200&lt;/A&gt;' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shingo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 13:50:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-v-4-x-cors/m-p/1329582#M82239</guid>
      <dc:creator>Shingo-Ikeda</dc:creator>
      <dc:date>2023-09-18T13:50:56Z</dc:date>
    </item>
  </channel>
</rss>

