<?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: Issues with CORS in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-cors/m-p/1219550#M78925</link>
    <description>&lt;P&gt;&lt;EM&gt;&amp;gt; is not an ESRI Api Key, but an API Key for an Azure API Management component&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Gotcha. You'll need to contact Azure technical support since that's their product. We don't have any control or knowledge of their security practices.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Oct 2022 19:14:14 GMT</pubDate>
    <dc:creator>AndyGup</dc:creator>
    <dc:date>2022-10-06T19:14:14Z</dc:date>
    <item>
      <title>Issues with CORS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-cors/m-p/1219249#M78912</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm currently implementing a solution for a client using the ArcGIS Javascript API. The solution requires some security which requires API keys and custom headers. When I'm adding the API key in the request URL I'm not having any CORS issues, whenever I'm adding the API key in the header I'm getting CORS issues. Even when I add&amp;nbsp;&lt;SPAN&gt;"Access-Control-Allow-Origin": '*' in my header I'm getting issues. Here is my code:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;ngOnInit&lt;/SPAN&gt;&lt;SPAN&gt;(): &lt;/SPAN&gt;&lt;SPAN&gt;void&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;config&lt;/SPAN&gt;&lt;SPAN&gt;.&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t;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;before&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;request&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;request.url = (&amp;lt;string&amp;gt;request.url).replace(AppConfig.settings.baseURL.url, AppConfig.settings.proxyURL.url)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;console&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;log&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;request&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;},&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;after&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;response&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;console&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;log&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;response&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; })&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;This is the error:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;Header&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;When I only add "Accept": '/' in my header I have no issues for example.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Can someone help me out?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Nicolas&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 09:59:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-cors/m-p/1219249#M78912</guid>
      <dc:creator>NicolasSwijngedouw</dc:creator>
      <dc:date>2022-10-06T09:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with CORS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-cors/m-p/1219326#M78916</link>
      <description>&lt;P&gt;I'm certainly no expert in CORS and bumble my way through most issues.&lt;/P&gt;&lt;P&gt;If I recall correctly the Access-Control-Allow-Origin header needs to be on the server side, rather than in the client request? Assuming you've shared client-side code?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 14:18:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-cors/m-p/1219326#M78916</guid>
      <dc:creator>LukeCalladine</dc:creator>
      <dc:date>2022-10-06T14:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with CORS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-cors/m-p/1219334#M78918</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/621601"&gt;@NicolasSwijngedouw&lt;/a&gt;If you inject unauthorized headers it will cause a CORS pre-flight error.&lt;/P&gt;&lt;P&gt;Here are a few resources to check out on the coding patterns for using API keys:&amp;nbsp;&lt;A href="https://developers.arcgis.com/documentation/mapping-apis-and-services/security/api-keys/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/secure-resources/#api-keys&lt;/A&gt;,&amp;nbsp; &lt;A href="https://developers.arcgis.com/documentation/mapping-apis-and-services/security/api-keys/" target="_blank"&gt;https://developers.arcgis.com/documentation/mapping-apis-and-services/security/api-keys/&lt;/A&gt; and &lt;A href="https://developers.arcgis.com/javascript/latest/display-a-map/#get-an-api-key" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/display-a-map/#get-an-api-key&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 14:27:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-cors/m-p/1219334#M78918</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2022-10-06T14:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with CORS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-cors/m-p/1219350#M78919</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/180"&gt;@AndyGup&lt;/a&gt;, thank you for your reply.&lt;/P&gt;&lt;P&gt;Is there any way to authorize custom headers on the server-side?&lt;/P&gt;&lt;P&gt;The API Key that I'm trying to include in my request header is not an ESRI Api Key, but an API Key for an Azure API Management component. That component is a reverse proxy on the edge of the network containing the ArcGIS Servers.&lt;BR /&gt;&lt;BR /&gt;In a near future, headers such as Authorization and Username are required as well and I will have to pass them via the header of the request.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 14:39:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-cors/m-p/1219350#M78919</guid>
      <dc:creator>NicolasSwijngedouw</dc:creator>
      <dc:date>2022-10-06T14:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with CORS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-cors/m-p/1219550#M78925</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; is not an ESRI Api Key, but an API Key for an Azure API Management component&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Gotcha. You'll need to contact Azure technical support since that's their product. We don't have any control or knowledge of their security practices.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 19:14:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/issues-with-cors/m-p/1219550#M78925</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2022-10-06T19:14:14Z</dc:date>
    </item>
  </channel>
</rss>

