Having trouble pointing to locally hosted Esri API "There was an error attempting to load ..."
See original GitHub issueWe are experimenting with the esri-loader and I can get it to work but only when I point the url to a cdn hosted version of the API. Our applications all have to hit an internally hosted copy of the arcgis js api - we can’t use CDN. When I point the esri-loader to the internally hosted api:
esriLoader. loadModules(["esri/arcgis/Portal", "esri/arcgis/utils", "esri/config"], { url: "https://localhost/esri/" }) .then([Portal, utils, config]) => { // do cool stuff });
I get and error in the console:
Uncaught (in promise) Error: There was an error attempting to load https://localhost/esri/ at HTMLScriptElement.onScriptError (esri-loader.js:76)
I’m guessing that the locally hosted version of the API isn’t quite what this package is expecting? We build it using the bower version of the API.
The bower.json file we use to create that internal copy of the arcgis-js-api has the following in the bower.json file.
{ “name”: “esri-internal”, “authors”: [ “xxxxx” ], “description”: “Local ESRI JSAPI resources for apps”, “main”: “”, “keywords”: [ “ESRI” ], “license”: “""”, “homepage”: “https://xxxxxxx/browse”, “private”: true, “dependencies”: { “arcgis-js-api”: “3.20.0” }, “resolutions”: { “dojo”: “v1.12.1/esri-3.20.0”, “dijit”: “v1.12.1/esri-3.20.0”, “dojox”: “v1.12.1/esri-3.20.0” } }
Would love to use the esri-loader but this is the blocker at the moment. Any idea what might be causing the error? Is this an issue with esri-loader or is it an issue with our internal build of the api? What can I do to debug?
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (8 by maintainers)
Top GitHub Comments
Thanks for clarifying.
In your case,
https://localhost/esri-api-v320/init.js
is the URL for your locally hosted copy of the API and that is what you should use.This is not an esri-loader issue. If you configured one of the sample pages to point to your locally downloaded copy of the API, you’d have to use
<script src="https://localhost/esri-api-v320/init.js"></script>
.The only reason
url: 'https://js.arcgis.com/3.26/'
works is b/c that server redirects (w/ a 301 no less!) tohttps://js.arcgis.com/3.26/init.js
:I suspect that your local build does not rewrite or redirect from
https://localhost/esri-api-v320/
, which is fine. There’s no rule that the build output script has to be calledinit.js
nor that you have to set up any fancy rewrites/redirects to hide whatever the file name may be.I wholeheartedly agree. Doing a Dojo build is a non-trivial undertaking, and in my experience is not worth the trouble.
Some might think that they can create a build of the API that only includes the modules they need in the build layer. I’ve never been able to make a build layer that is any more efficient than the compact build.