Select to view content in your preferred language

Got CORS error accessing services.arcgisonline.com from localhost (debugging locally)

662
1
Jump to solution
11-10-2022 06:23 AM
Gurunara
Occasional Contributor

Got CORS error accessing services.arcgisonline.com from localhost (debugging locally). This was happening with just referencing basemaps, which are apparently linking to services.arcgisonline.com.

Current js library version is js.arcgis.com/3.41.

Using workaround during map initialization, which seems to work:

if (esri.config.defaults.io.corsEnabledServers.indexOf('services.arcgisonline.com') !== -1)
esri.config.defaults.io.corsEnabledServers.splice(esri.config.defaults.io.corsEnabledServers.indexOf('services.arcgisonline.com'), 1);

which basically removes 'services.arcgisonline.com' from the esri.config.defaults.io.corsEnabledServers array.

But is there a standard way of preventing this cors error?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Gurunara
Occasional Contributor

Above workaround works... but the root cause may be due to the web server redirecting https to http. Make sure that webserver on which the web map runs does not do this. Http seems to lead to cors error.

View solution in original post

0 Kudos
1 Reply
Gurunara
Occasional Contributor

Above workaround works... but the root cause may be due to the web server redirecting https to http. Make sure that webserver on which the web map runs does not do this. Http seems to lead to cors error.

0 Kudos