To test an application, I created a sample GeoJSON on my AWS and passing its URL to the GeoJSON Layer JS API to access it - however I am facing CORS issue.
For now I am able to bypass it with disabling Chrome security, however, I wanted to know if there is any means to pass appropriate Request headers to fix this for final.
I tried:
var options = {
query: {
f: "json"
},
responseType: "json",
mode: "no-cors"
};
and also
var options = {
query: {
f: "json"
},
responseType: "json",
headers: {
"Access-Control-Allow-Headers": "*"
}
};
when I am using require(["esri/request"] but to no success - its still throwing the same error. What am I missing here?
I even tried with "Access-Control-Allow-Origin": "*" but then it gives the error "Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response."
Robert Scheitlin, GISP - Anything you could help me with?
Couple ideas to try:
1) esriConfig.request.trustedServers
https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request
Indicates whether cross origin requests made to the associated server should include credentials such as cookies and authorization headers.
2) CORS guide page
https://developers.arcgis.com/javascript/latest/guide/cors/index.html
3) Try using a proxy
Hi Noah,
I had gone through these links but was looking more for a sample application - anyways for now we managed to enable the service as CORS enabled, so issue resolved.