I have set up a proxy page. I am using JSP version of proxy page. I have set up a server URL which will point to my Java. When I load the my page which the proxy URL has set in its html it will work fine only in IE but not in Mozilla or Chrome.

Even in IE it will work only if I use localhost, but if I use my IP then it won't work.

In Chrome I get: Origin http://<localhost> is not allowed by Access-Control-Allow-Origin.

In Mozilla when I check the response I get the login page for the REST services.

Is this issue related to cross domain or what?

I haven't checked to see if my proxy is working; my question is how do I check it. I think it should be working since in IE when I use localhost instead of my IP it works fine.

In Mozilla in Firebug when I check I see the response is the login page for REST service.

I am running my proxy server in my Websphere which is running in port 9080; my web server is Apache HTTP server which is running on port 80 and my ArcGIS server is running in another machine on port 6080.

Proxy server : WebSphere
proxy url : localhost:9080/proxy/proxy.jsp
web server : apache
web server url : localhost
Arcgis server:<some-ip>:6080

Below is more complete code:

<!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10"> 
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples 
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>FeatureLayer On Demand</title> 
    <link rel="stylesheet" href="http://js.arcgis.com/3.6/js/dojo/dijit/themes/claro/claro.css"> 
    <link rel="stylesheet" href="http://js.arcgis.com/3.6/js/esri/css/esri.css">
      html, body, #mapDiv {
    <script src="http://js.arcgis.com/3.6/"></script> 
      var map,featureLayer;
      require(["dojo/on", "esri/map", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/InfoTemplate", "esri/layers/FeatureLayer",
               "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "dojo/_base/Color", "esri/graphic",
               "dojo/parser", "dojo/domReady!"
      ], function(
        on,Map, ArcGISDynamicMapServiceLayer, InfoTemplate, FeatureLayer, SimpleFillSymbol, SimpleLineSymbol, Color, Graphic,  
      ) {
        esri.config.defaults.io.proxyUrl = "http://localhost:9080/proxy/proxy.jsp";
        var initExtent = new esri.geometry.Extent({"xmin":-21744805.806561172,"ymin":-4911537.689490959,"xmax":3302079.6219187006,"ymax":13090911.21222895,"spatialReference":{"wkid":102100}});

        map = new Map("mapDiv", { 
          extent: initExtent        

        var WorldCountries = new ArcGISDynamicMapServiceLayer("");

        map.on("load", initOperationalLayer);

        function initOperationalLayer() {
         featureLayer = new FeatureLayer("",{
            mode: esri.layers.FeatureLayer.MODE_SELECTION,
          outFields: ["*"],
          opacity: 0.75

          var sfs = new SimpleFillSymbol(SimpleFillSymbol.STYLE_FORWARD_DIAGONAL, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.5]));


          on(map,"click", function(evt){

                /*var query = new esri.tasks.Query();
                query.geometry = evt.mapPoint;
                featureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW, function (features){
                    map.infoWindow.setTitle("Country Information");
                    map.infoWindow.setContent("Country Name: " + features[0].attributes.COUNTRY);


      function showCountries(){
            var queryTask = new esri.tasks.QueryTask("");
            //build query filter
                console.log(" showCountries");
                        var query = new esri.tasks.Query();
                        query.returnGeometry = true;
                        query.where = "CNTRY_NAME IN ('India','Brazil','Italy','Australia','France','Libya','Russia','Ukraine','United States','Canada','Zimbabwe','Zambia','Yemen','Vietnam','Venezuela','Vanuatu','Uzbekistan','Uruguay','United States Minor Outlying Islands','United Kingdom','United Arab Emirates','Uganda','Tuvalu','Turks and Caicos Islands','Turkmenistan','Tajikistan','Turkey','Tunisia','Trinidad & Tobago','Tonga','Togo','Timor-Leste','Turkmenistan','Thailand','Tanzania','Palestinian Territory','Panama','Papua New Guinea','Paraguay','Poland','Portugal','Qatar','Romania','Greenland','Mexico','South Africa','South Korea','Spain','Sudan','Sri Lanka','Switzerland','Sweden','St. Vincent & the Grenadines','St. Pierre & Miquelon','Singapore','Indonesia','Colombia','Congo, DRC','Cook Is.','Costa Rica','Croatia','Cyprus','Czech Republic','Cameroon','Democratic Republic of the Congo','Antarctica','Armenia','Austria','North Korea','Romania','Rwanda','Norway','Monaco','Mauritania','Mauritius','Madagascar','Isle of Man','Iceland','Hungary','Germany','Antigua & Barbuda','Azerbaijan','Barbados','Belarus','Belgium','Bermuda','Bhutan','Bosnia & Herzegovina','British Indian Ocean Territory','British Virgin Is.','Central African Republic','Chad','Chile','Christmas I.','Egypt','Ethiopia','Finland','Vatican City','Western Sahara','Syria','Pakistan','Guyana','Mongolia','Nepal','Palau','Jamaica','Italy','Isreal','Fiji','Bermuda','Bhutan','Bolivia','The Bahamas','The Gambia','Montserrat','Mozambique','Morocco','Moldova','Kazakhstan','Myanmar','Sudan','Argentina','Bolivia','Algeria','Niger','Mali','Bolivia','Saudi Arabia','Botswana','Angola')";
                        query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS;
                        //query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;
                        var spRef = new esri.SpatialReference({wkid : 102100});
                        query.outSpatialReference = spRef; // Doesn't work  
                        //query.outSpatialReference = map.spatialReference; // Doesn't work either
                        infoTemplate = new esri.InfoTemplate("Alert", "Alert for Re-insurance");
                        console.log(" infoTemplate "+infoTemplate);
                        dojo.connect(queryTask, "onComplete", function(featureSet) {
                                    console.log(" query complete");
                                    var symbol0 = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 0, 0, 0.9]));
                                        var graphic = feature;

      function requestData(evt){
                console.log(" request data");
                    url: "http://earthquake.usgs.gov/earthquakes/feed/geojson/1.0/week",
                    handleAs: 'json',
                    load: function(data){ 
                          var query = new esri.tasks.Query();
                            query.geometry = evt.mapPoint;
                            featureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW, function (features){
                    error: dojo.hitch(this, "failure")

      function showData(){
        console.log("in showdata");

      function failure(){

      function calcOffset() {
  return (map.extent.getWidth() / map.width);
  // console.log('extent changed...maxOffset: ', globals.maxOffset);
  <body class="claro"> 
    <div id="mapDiv">
  • 1
    You will have to give us more details before we can answer this question. Details like have you checked your proxy is correctly working? how did you check it? How have you set the proxy in the JavaScript App? When does this error happen? What is the domain/host name of your webserver? What is the domain/host name of your ArcGIS server? The question as it currently stands, is not answerable. Sep 12, 2013 at 10:47
  • I have edited my question to give all the details
    – Anil
    Sep 12, 2013 at 10:58
  • Have you set the serverUrls properly in your proxy? And never check things with localhost; Always use the full hostname, so that you can check the application in real world conditions. Sep 12, 2013 at 10:59
  • I have set the serverUrl to point to my arcgis server.I even checked with Token but no difference
    – Anil
    Sep 12, 2013 at 11:03
  • It will be very difficult to solve your issue without having complete details of your configuration. I'll recommend that you go through this: help.arcgis.com/en/webapi/javascript/arcgis/jshelp/#ags_proxy and follow all the given steps. Best of Luck! Sep 12, 2013 at 11:09

3 Answers 3


Try to add a response header for:

Access-Control-Allow-Origin: *

in your proxy page.


I'm not sure if I read your question correctly, but CORS has problems when running from local host. Whenever I work with CORS in javascript, I have to upload the page to my website and run it from there. It will always fail running from my local drives.


I used to have that issue with testing with 'localhost' on development machine using Netbeans 8.0. Then, during some of my playing around with settings, I discovered that while on local machine, turn 'alwaysuseProxy' to false. Layers all display as planned and site works fine (on port 8383). On the live production server, turn 'alwaysuseProxy' back to true. And for some reason, trying to use CORS doesn't work, even though my IIS 7 server is setup with proper header and 'tests' as CORS compatible server. So I just 'alwaysuseProxy' on live server.

Your Answer

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

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