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?
Solved! Go to Solution.
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.
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.