I created simple simple web site:

    ], function (
       ) {
        esriConfig.defaults.io.proxyUrl = ""
        esriConfig.defaults.io.alwaysUseProxy = true;
        var customExtentAndSR = new esri.geometry.Extent(-437000, -1244500, -409000, -1239500, new esri.SpatialReference({ wkid: 5514 }));
        map = new Map("mapDiv", { logo: false, extent: customExtentAndSR, nav: false, slider: false, fitExtent: true, fadeOnZoom: true, showAttribution: false });
        var infoWindow = new InfoWindowLite(null, domConstruct.create("div", null, null, map.root));

 var template = new InfoTemplate();
var featureLayer = new esri.layers.FeatureLayer("", {
 mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
 infoTemplate: template,
 outFields: ["*"]

When I use "MODE_SNAPSHOT" for my featurelayer, layer is displayed and is possible to display infotemplate. But when I run my web site again, It seems to be problem with CORS (No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:12345' is therefore not allowed access.). Once is everything OK, once not. When I run my web site 10 times, approximatelly 5 times is problem with CORS. When I use "MODE_ONDEMAND" it´s OK but when I zoom my layer, problem with CORS is displayed and zoomed layer is not displayed. When I used this sample code with the same layer but as dynamicservicelayer with labels, It seems to be OK. Could someone help me with this problem ? Is it problem with settings in proxy ?

1 Answer 1


When communicating to a service using the Esri Javascript API, a proxy page will only avoid CORS issues if the proxy page uses the same URL prefix as the original web site.

So, if your web site is http://localhost:12345/path/to/index.html, the request to: ...is still crossing an origin and will trigger the CORS preflight and checks.

If you can run the proxy page somewhere behind http://localhost:12345, then you should not see the CORS errors.

I'm not sure why you only see the problem about half the time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.