require(["esri/config"], function(esriConfig) { esriConfig.defaults.io.corsEnabledServers.push("yourhostname.com"); });
Actually, I don't want to add proxy page, it would be bit hassle for my customers. I want to handle somehow for webserver configuration part dynamically or whenever I send request if I can change the header. Wondering if changing header with the request is possible through esr/request. I tried esriConfig.defaults.io.corsEnabledServers as you suggested but still gives an error. May be because of the restriction available at webserver level. Is there anything can be done at ArcGIS Server level to enable CORS? I am using ArcGIS Server 10.0.
This error is usually due to the API's automatic detection of CORS support. The JSAPI attempts to access the rest endpoint of the service. If the service doesn't support CORS the request fails and the error you see is logged to the console.
In cases where CORS support is not available either due to lack of browser support for CORS or if the service you are making cross domain requests to does not support it you may need to setup a proxy for use by your application. Details on installing and configuring the proxy can be found here: Esri/resource-proxy · GitHub