Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This question already has an answer here:

I use OpenLyaers in order to show france Departements. My website is generated in ASP .NET MVC 4 (i use Visual studio 2012) ans i use GeoServer to store WFS files.

I want to access to my WFS layer by

var wfs =  new OpenLayers.Layer.Vector("States", {
            strategies: [new OpenLayers.Strategy.BBOX()],
            protocol: new OpenLayers.Protocol.WFS({
                url: "http://localhost:8080/geoserver/wms",
                featureType: "states",
                featureNS: "http://www.openplans.org/topp"
            })
            });


map.addLayer(wfs);

In Google Chrome console i have :

XMLHttpRequest cannot load http://localhost:8080/geoserver/wms. Origin http://localhost:50431 is not allowed by Access-Control-Allow-Origin. 

How i can parametre Geoserver to solve this problem ?

share|improve this question
add comment

marked as duplicate by iant, Devdatta Tengshe, Aragon, Zachary, R.K. Feb 17 '13 at 15:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

you are trying to do some cross-domain request, qhich are denied by default as defined by the Same origin Policy. There are 2 solutions:

  1. For debug only, you can start chrome with the option:

    chrome.exe --disable-web-security

  2. The modern browser allow cross-domain ajax if the server add a particular header in the response. Now it depends under which server Geoserver is running. If it's jetty, you can allow cross-domain as described in the Jetty wiki.

share|improve this answer
    
Thank you for your answer. Geoserver run with jetty (i have Geoserver 2.4 installed with windows installer). I did what it is explained in the jetty Wiki but Now i have this mistake when i want to open the geoserver page : HTTP ERROR: 503 SERVICE_UNAVAILABLE RequestURI=/geoserver/web/ Powered by jetty:// Maybe i havent' get the good jetty-servlets.jar in the good directory. How i can know which choose and where place it ? –  ROCHEDY Feb 11 '13 at 15:26
    
@ROCHEDY try this link <gis.stackexchange.com/questions/32407/…; –  Tommaso Feb 11 '13 at 15:57
add comment

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