CORS Support on services.arcgisonline.com?

2883
3
03-13-2012 03:16 PM
RyanClark
New Contributor II
I often have javascript web applications that want to use tiled services from http://services.arcgisonline.com, but before using them I would like to get some tiling and copyright information. Generally, I would do that by first issuing a request like http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer?f=json, and parsing the response to find the tiling information.

The trouble is that because my web application is on one server, and the services are on another, the web browser viewing my application will not make the request:
GET http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServerf=json 404 (Not Found)
XMLHttpRequest cannot load http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServerf=json. Origin http://bukovite is not allowed by Access-Control-Allow-Origin.
leaflet-custom.js:6Uncaught TypeError: Cannot call method 'replace' of undefined


This is a cross-origin request issue, and modern web browsers will allow such requests if the server the request is sent to returns the following header:
Access-Control-Allow-Origin: *
. See http://enable-cors.org/ for more information.

Is there any chance that at some point in the future, the servers at http://services.arcgisonline.com might allow CORS requests?

Thanks,
Ryan
Tags (2)
0 Kudos
3 Replies
MikeMinami
Esri Notable Contributor
services.arcgisonline.com doesn't currently support CORS, but will once migrated to ArcGIS Server 10.1.

From what I was told, however, CORS is not required for this. You should be able to use jsonp. Does that make sense to you? If not, try posting in this forum.

http://forums.arcgis.com/forums/15-ArcGIS-API-for-JavaScript

Thanks,

Mike
0 Kudos
RyanClark
New Contributor II
From what I was told, however, CORS is not required for this. You should be able to use jsonp.


Yep, I was able to make it work with jsonp, but it is somewhat clumsier to code in this situation. Good to hear that CORS will be supported in the not-too-distant future.
0 Kudos
KevinRing
New Contributor
Sorry to revive an old thread.  I have a similar problem, except that I want to use the actual tiled images in a scene rendered with WebGL.  Unfortunately, WebGL cannot display images unless they were loaded from the same origin or retrieved through a successful CORS request.  So, is there a timeframe for upgrading services.arcgisonline.com to 10.1?  If it affects the answer at all, I'm actually more interested in CORS-enabled access to the beta World Elevation services (https://elevation.arcgisonline.com).  If it's going to be awhile before these servers are upgraded, is there any chance of adding the necessary header to the existing servers?  From what I understand, it should be quite easy to do.  The link in the original post has more information: http://enable-cors.org/.

Thanks,
Kevin
0 Kudos