1

This question already has an answer here:

My Gis Client Program, using OpenLayers, and my GeoServer were running on the same server, everything worked fine.

Now, I started a new instance of My Gis Client Program on another server. There, I get the following Problem:

WMS Layers work fine, but for the WFS Layer I get: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://mygeoserver/mylayerr. This can be fixed by moving the resource to the same domain or enabling CORS.

What can I do about that?

marked as duplicate by Ian Turton Jul 30 '17 at 16:26

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.

  • 3
    Well, you could move the resource or enable CORS. CORS seems like the right answer, and there is a previous answer for this for openlayers gis.stackexchange.com/questions/71715/…. Does that solve your problem? – BradHards Dec 3 '14 at 10:06
  • 2
    As an alternative you need to go through a proxy (beware of the implications) to be installed on the same domain of GeoServer. – simogeo Dec 3 '14 at 10:26
  • The Problem is for me only the WFS Layer, the WMS works perfectly. If I add tileOptions: {crossOriginKeyword: 'anonymous'}, transitionEffect: null, to the Layer Object, it does not change anything. – Ferenjito Dec 3 '14 at 11:19
  • You need to enable CORS on the server with the layers. Adding anything to JS on the client side cannot solve the problem. If you cannot adjust CORS settings of the server, just use a proxy (written e.g. in PHP) to proccess your requests. – Michal Zimmermann Dec 4 '14 at 14:21
  • @MichalZimmermann and how can we do it on the server alone? – Oualid Fouad Jul 1 '16 at 16:41