Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I got the typical cross-domain problem when access to WFS layer by using openlayers,

XMLHttpRequest cannot load http://XXXX/geoserver/ows?service=WFS. Origin http://XXXX is not allowed by Access-Control-Allow-Origin.

I did some research about how to handle this. it seems that a web proxy solution is a good. so I edited a file, and put it at the root of my IIS server. however, it seems that I need to explicitly put the following code somewhere:

Openlayers.ProxyHost = "/cgi-bin/" 

but I don't know where to put. If I put like below:

var map;
Openlayers.ProxyHost = "/cgi-bin/" 

   //more code

It will popup an error saying "OpenLayers is not recognized".

Any hints? thank you all!

share|improve this question
up vote 1 down vote accepted

You should put that line after you load the Open Layers javascript file(s) and before you start creating your map

<script src='/path/to/openlayers.js' />
      alert('woo hoo! Open layers object is now loaded'); 
      Openlayers.ProxyHost = "/cgi-bin/";
      // you shouldn't be seeing this if OL path is correct
      alert('uh-oh! where's my Open Layers object??'); 
share|improve this answer
i realized i just made a stupid mistake.. but anyway, i solved it now..thanks buddy. – Simon Aug 11 '11 at 17:57
Ohhh, I think I see it now too. Was it just lower case "L" in OpenLayers vs Openlayers?! Ouch :) Well, either way glad it's working now. Next time please post what your own solution was if the one on the board wasn't it. – Vadim Aug 11 '11 at 22:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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