Search code examples
openlayersopenstreetmap

OpenLayers2 No 'Access-Control-Allow-Origin' header error


I am trying to update a (several year old) OL2 JS app with a new OSM layer

My layer code is:

                        var osm = new OpenLayers.Layer.OSM(
                                "Hydda",
                                ["http://a.tile.openstreetmap.se/hydda/full/${z}/${x}/${y}.png"],
                                {crossOriginKeyword: null}
                        )

I cannot get the tiles to load without the following error:

Image from origin 'http://a.tile.openstreetmap.se' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://mysite' is therefore not allowed access.

Any ideas? The crossOriginKeyword declaration should handle this, right?


Solution

  • This was apparently related to a corporate firewall misconfiguration, and not a result of OpenLayers config.