In order to prevent direct url access to download files on my website I use following HTTP header which is setted by the following JavaScript during the click on download url:
$('a.download').on('click', function(){
$.ajax({
url: '/ajax/preventDownload',
headers: { 'x-rarity-download-header': 'download' }
});
})
Server checks if this 'x-rarity-download-header' present in HTTP request and if no doesn't allow user to download file.
Right now this approach works not in the all browsers, for example it works in FireFox 50 and looks like doesn't work on some previous versions like 48. Also, this approach doesn't work in Safari browser.
What can be a reason of this and how to fix it ?
beforeSendor use a different method?