Requesting Documents from filing history

using the following:-
$(document).ready(function () {
var settings = {
“dataType”: “json”,
“async”: true,
“crossDomain”: true,
“url”: “https://document-api.companieshouse.gov.uk/document/hNbsxQ32rS3uPgZRcCd-wxV1tXsGZ0Ik3E_tYva8iWw/content”,
“method”: “GET”,
“headers”: {
“Accept”: “application/pdf”,
“authorization”: "Basic "
}
}
$.ajax(settings).done(function (response) {
alert ("IT WORKED " + response);
})
})
// JavaScript Document

yet i get the following:-

XMLHttpRequest cannot load https://document-api.companieshouse.gov.uk/document/hNbsxQ32rS3uPgZRcCd-wxV1tXsGZ0Ik3E_tYva8iWw/content. Redirect from ‘https://document-api.companieshouse.gov.uk/document/hNbsxQ32rS3uPgZRcCd-wxV1tXsGZ0Ik3E_tYva8iWw/content’ to ‘https://s3-eu-west-1.amazonaws.com/document-api-images-prod/docs/hNbsxQ32rS…e1%2B5qP%2Bfkon85OT9qCW%2FwmgUgO5bNJlKme9lzNxIhJT53j3Cl2KavCso1%2FSeywU%3D’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://www.(my domain).com’ is therefore not allowed

there seems to be no way of stopping ajax following the redirect link…

Don’t think AJAX can stop this as per the spec. I don’t know how to work round the CORS offhand (we do processing back-end so it’s not an issue). Maybe start here:

https://stackoverflow.com/questions/8238727/how-to-prevent-ajax-requests-to-follow-redirects-using-jquery

Good luck.