AnsweredAssumed Answered

ArcGIS JS API: Custom build, mapserver 501 error

Question asked by mariam.dost on Oct 25, 2016

I followed the instructions to create a local copy of the arcgis js api 4.1. When I run my project I get a CORs error saying: 

OPTIONS http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer?f=json

XMLHttpRequest cannot load http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer?f=json. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4000' is therefore not allowed access. The response had HTTP status code 501.

 

This error is odd b/c the API should not make preflighted (options) request to this url, it should make a get request (originally thats what it does). I have tried all the esri/config options to disable the cors but nothing seems to work. It doesn't load the map tiles. Anyone know how I can fix this?

 

Below is the config file for my project:

requirejs.config({
paths: {
"jquery": 'https://code.jquery.com/jquery-3.1.0.min',
'esri/moment': 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment',
"esri": "../lib/main",
"dojo": 'http://js.arcgis.com/4.1/dojo',
"dojox": 'http://js.arcgis.com/4.1/dojox'

}

...

});

Outcomes