question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Having trouble pointing to locally hosted Esri API "There was an error attempting to load ..."

See original GitHub issue

We 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:closed
  • Created 5 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
tomwaysoncommented, Oct 3, 2018

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!) to https://js.arcgis.com/3.26/init.js:

image

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 called init.js nor that you have to set up any fancy rewrites/redirects to hide whatever the file name may be.

0reactions
tomwaysoncommented, Oct 3, 2018

I know you also mentioned that I could run a dojo build manually of the bower source files for the API and point to that - not sure I really see the benefit of doing that

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to load image layer via localhost in Angular
Solved: I am trying to add three layer with different capability in a map viewer. All layers were loading just fine.
Read more >
The hosted feature layer is unable to load in ArcGIS Online
Solution or Workaround. Depending on the cause, follow either of the workarounds below to resolve the issue. Clear the browser cache. Clearing ...
Read more >
Mysterious "There was an error" error. - Esri Community
I have a hosted feature layer in ArcGIS Online that accepts edits from an ArcGIS Server application. Permissions on the feature layer are ......
Read more >
Chart not working - Esri Community
I have tried: Seveal different chart types (bar, scatter plot, histogram etc.) Saving the layer locally (originally it was a hosted layer on ......
Read more >
Problem with Arcgis Enterprise 10.6.1 after applyi...
We have Portal and Server federated and Data Store. ... Unable to load https://MachineName/portal/sharing/rest/portals/self?f=json status: 0.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found