AnsweredAssumed Answered

Use ArcGIS API from another host server, using esri-loader

Question asked by sal.fiesta on Sep 15, 2020

We have a ReactJS app that uses the esri-loader library to lazy-load the map API. Everything works well when we use the esri-loader defaults. Now, we have to bring our app in a network that has no access to the default, but must pull from another server that hosts the ArcGIS API. I know that the default URL is https://js.arcgis.com/4.16/ so I changed it. I tried passing an option with the url property like this:

{url: 'https://internal-server.com/4.x/', css: 'https://internal-server.com/4.x/css/main.css'}

Unfortunately, the map fails to load. Looking at the browser dev tools' network tab, the issue is because dojo.js (or dojo-lite.js) cannot be found in https://internal-server.com/4.x/, I need to explicitly set the option's url property to https://internal-server.com/4.x/dojo/dojo-lite.js

 

That works in loading the dojo script, but the map fails again. I looked at the network tab and noticed that although the CSS and dojo-lite loaded, the URL for things like the Map.js and MapView.js, etc. are missing the base URL. So instead of https://internal-server.com/4.x/esri/views/MapView.js , I'm seeing https://esri/views/MapView.js , etc. I checked the server that hosts the API and https://internal-server.com/4.x/esri/views/MapView.js, along with the other scripts do exist. It's just that esri-loader doesn't seem to set the base URL. I've been following this documentation (esri-loader - npm), but having zero luck. I even tried passing a dojoConfig option with a baseUrl, property, but that didn't seem to help. Please help. Thanks in advance!

Outcomes