Hello all,
My companies GIS team has created a ArcGIS REST API for us developers to use. It allows us access to the GIS data so we can display the GIS data on our frontend products. I currently have created an endpoint that queries a data layer and returns the query in GeoJSON format. The requests work great on Postman (as expected) however when I make a request from our staging environment in development I get this CORS error.
Access to XMLHttpRequest at '<our endpoint>' from origin 'https://allocommunidev.wpenginepowered.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
My question becomes, is this a frontend CORS error? From what I have read ArcGIS allows ALL cross origin requests which leads me to believe this is a frontend error, but I have no good way to tell and be certain. However I have tried many things. This is the jQuery and AJAX request. Any help would be much appreciated
$.ajax({
url: tokenEndpoint,
type: "POST",
data: {
username: username,
password: password,
client: "referer",
referer: "https://stgallocomm.wpenginepowered.com",
expiration: 60,
},
success: function (response) {
if (response) {
console.log(response);
let token = response;
$.ajax({
url: NeCentralPons,
type: "GET",
beforeSend:
function (xhr) {
xhr.setRequestHeader('Authorization', `Bearer ${token}`);
console.log(`Bearer ${token}`);
},
success: function (data) {
console.log(data);
},
error: function (error) {
console.error(error.status)
}
});
} else {
console.error("Token failed:", response);
}
}
});