<?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 add a proxy to the arcgis-js-api Webpack Typescript demo app? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-a-proxy-to-the-arcgis-js-api-webpack/m-p/1048959#M72639</link>
    <description>&lt;P&gt;We are using React and TypeScript, this works for us:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;*&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;urlUtils&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'@arcgis/core/core/urlUtils'&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;urlUtils&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;addProxyRule&lt;/SPAN&gt;&lt;SPAN&gt;({&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;});&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 20 Apr 2021 02:09:19 GMT</pubDate>
    <dc:creator>HenryKo2</dc:creator>
    <dc:date>2021-04-20T02:09:19Z</dc:date>
    <item>
      <title>How to add a proxy to the arcgis-js-api Webpack Typescript demo app?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-a-proxy-to-the-arcgis-js-api-webpack/m-p/261401#M24198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have created an application based upon the ArcGIS Javascript API 4.9 Webpack demo application (&lt;A href="https://github.com/Esri/jsapi-resources/tree/master/4.x/webpack" rel="nofollow noopener noreferrer" target="_blank"&gt;https://github.com/Esri/jsapi-resources/tree/master/4.x/webpack&lt;/A&gt;&lt;A class="unlinked" target="_blank"&gt;). The application is written in Typescript and is structured in the same manner as the demo. It currently works fine with unsecured services. However, I wish to add a proxy so that the application will use secured services, but so far have been unable to get urlUtils.addProxyRule() to work in the Typescript environment.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried adding the call to the demo/src/data/app.ts file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import esri = __esri;
import urlUtils from "esri/core/urlUtils";
import MapImageLayer from "esri/layers/MapImageLayer";
...
urlUtils.addProxyRule({
&amp;nbsp;&amp;nbsp;&amp;nbsp; urlPrefix: "my.server.com",
&amp;nbsp;&amp;nbsp;&amp;nbsp; proxyUrl: "https://path.to.proxy/proxy.ashx"
});&lt;/PRE&gt;&lt;DIV style="padding-left: 30px;"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;export const myLayer = new MapImageLayer({
&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; url: "&lt;/SPAN&gt;&lt;A _jive_internal="true" href="https://community.esri.com/my.server.com/arcgis/rest/services/myService/MapServer" target="_blank"&gt;https://my.server.com/arcgis/rest/services/myService/MapServer&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; sublayers: [{id: 0}],
&amp;nbsp;&amp;nbsp;&amp;nbsp; opacity: 1.0
});&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also tried adding the call to the demo/src/widgets/App.tsx file:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import esri = __esri;
import urlUtils from "esri/core/urlUtils";
...
private onAfterCreate(element: HTMLDivElement){
&amp;nbsp;&amp;nbsp;&amp;nbsp;urlUtils.addProxyRule({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urlPrefix: "my.server.com",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proxyUrl: "https://path.to.proxy/proxy.ashx"
&amp;nbsp;&amp;nbsp;&amp;nbsp;});
&amp;nbsp;&amp;nbsp; import("./../data/app).then(...)
}&lt;/PRE&gt;&lt;P&gt;In both instances, the application fails on the urlUtils.addProxyRule call:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Uncaught TypeError: Cannot read property 'addProxyRule' of undefined&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have coded a number of applications in the JSAPI 3.x and 4.x, but this is my first using Typescript and Webpack, so I'm at a bit of a loss as to the error. Any assistance or guidance would be greatly appreciated. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:49:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-a-proxy-to-the-arcgis-js-api-webpack/m-p/261401#M24198</guid>
      <dc:creator>JeffKapellas</dc:creator>
      <dc:date>2021-12-11T12:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a proxy to the arcgis-js-api Webpack Typescript demo app?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-a-proxy-to-the-arcgis-js-api-webpack/m-p/261402#M24199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So after a bit of trial-and-error, I was able to resolve the issue by changing the import statement from&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;import urlUtils from "esri/core/urlUtils";&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; import urlUtils = require("esri/core/urlUtils");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That same change also fixed a similar issue I was experiencing with promiseUtils. It's not clear to me when you use one syntax of the other, but the fix works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Dec 2018 01:30:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-a-proxy-to-the-arcgis-js-api-webpack/m-p/261402#M24199</guid>
      <dc:creator>JeffKapellas</dc:creator>
      <dc:date>2018-12-11T01:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a proxy to the arcgis-js-api Webpack Typescript demo app?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-a-proxy-to-the-arcgis-js-api-webpack/m-p/261403#M24200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for this solution it helps me with similar esri/core/promiseUtils.&lt;/P&gt;&lt;P&gt;After some testing, I figured out that ES6 notation of this kind work as well:&lt;/P&gt;&lt;PRE class="language-javascript line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt; create &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"esri/core/promiseUtils"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;or better&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;PRE class="language-javascript line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt; create &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; promiseCreate&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"esri/core/promiseUtils"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Zdenek J.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Oct 2020 07:49:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-a-proxy-to-the-arcgis-js-api-webpack/m-p/261403#M24200</guid>
      <dc:creator>ZdeněkJankovský</dc:creator>
      <dc:date>2020-10-07T07:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a proxy to the arcgis-js-api Webpack Typescript demo app?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-a-proxy-to-the-arcgis-js-api-webpack/m-p/1048959#M72639</link>
      <description>&lt;P&gt;We are using React and TypeScript, this works for us:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;*&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;urlUtils&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'@arcgis/core/core/urlUtils'&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;urlUtils&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;addProxyRule&lt;/SPAN&gt;&lt;SPAN&gt;({&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;});&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 20 Apr 2021 02:09:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-a-proxy-to-the-arcgis-js-api-webpack/m-p/1048959#M72639</guid>
      <dc:creator>HenryKo2</dc:creator>
      <dc:date>2021-04-20T02:09:19Z</dc:date>
    </item>
  </channel>
</rss>

