AnsweredAssumed Answered

Using Proxy with JavaScript API 4.0

Question asked by joshua.oregon on Jun 1, 2016
Latest reply on Jun 8, 2016 by joshua.oregon


Has anybody tried using the proxy to access a secure service with the 4.0 JavaScript API?  When I use the proxy, I can see in my network traffic that it is properly accessing the service, but nothing is displayed on the map.  This indicates the proxy is working fine, but the API isn't then adding the result to the map.  I tried with both username/password, and token in my proxy.

 

The code is pretty boilerplate, but here it is if interested:

 

require([
      "esri/Map",
      "esri/views/MapView",
      "esri/layers/FeatureLayer",
      "esri/core/urlUtils",
      "esri/config",
      "dojo/domReady!"
    ], function(Map, MapView, FeatureLayer, urlUtils, esriConfig) {

      var map = new Map({
        basemap: "streets"
      });

      var view = new MapView({
        container: "viewDiv",
        map: map,
        zoom: 10,
        center: [-122.668872, 45.511788]
      });

      urlUtils.addProxyRule({
        proxyUrl: '.<<path to proxy>>',
        urlPrefix: '<<baseurl to use proxy>>'
      });

      var featureLayer = new FeatureLayer({
        url: "<<secure feature service>>"
      });

      map.add(featureLayer);

 

I had to switch back to 3.16, which used the proxy and added the layer perfectly.  Oddly enough, if I signed into ArcGIS Server in the same browser, the service would display fine in my 4.0 app.

Outcomes