I'm trying to access an AWS API Gateway with jQuery like:
$.ajax({
method: 'GET',
url: _config.api.invokeUrl + '/mymodel/' + id + '/attr',
headers: {
Authorization: authToken
},
data: {},
contentType: 'application/json',
success: function(result){
console.log('success:'+result);
},
error: function ajaxError(jqXHR, textStatus, errorThrown) {
console.error('Error: ', textStatus, ', Details: ', errorThrown);
console.error('Response: ', jqXHR.responseText);
}
});
However, jQuery/browser reports the CORS error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://sd98fsf98.execute-api.us-east-1.amazonaws.com/test/mymodel/123/attr. (Reason: CORS request did not succeed).
Clearly, I can't fix it by hosting my code from sd98fsf98.execute-api.us-east-1.amazonaws.com
. I can't find any option in the Gateway API settings to disable this check. How do I bypass the CORS restriction?