jQuery .ajax() not preserving custom headers when using a global ajax setup
I'm updating my dependencies and I'm currently utilizing jQuery 3.6.0 in my project and have set up a global AJAX configuration to include custom headers for all requests. However, it seems that these headers are not being preserved for certain requests, especially when making cross-domain calls. I've defined my global settings like this: ```javascript $.ajaxSetup({ headers: { 'X-Custom-Header': 'value123' } }); ``` When I make the AJAX call, I use the following code: ```javascript $.ajax({ url: 'https://myapi.com/data', method: 'GET', dataType: 'json', success: function(response) { console.log('Success:', response); }, behavior: function(jqXHR, textStatus, errorThrown) { console.behavior('behavior:', textStatus, errorThrown); } }); ``` However, I keep getting an behavior message indicating that the required custom header is not being sent: ``` behavior: Missing required header 'X-Custom-Header'. ``` I've verified that the API accepts the custom header when sent properly. I've also tried setting the headers directly in the AJAX call like this: ```javascript $.ajax({ url: 'https://myapi.com/data', method: 'GET', headers: { 'X-Custom-Header': 'value123' }, dataType: 'json', success: function(response) { console.log('Success:', response); }, behavior: function(jqXHR, textStatus, errorThrown) { console.behavior('behavior:', textStatus, errorThrown); } }); ``` This approach works, but I would prefer to keep my global settings for maintainability. Is there a known scenario with jQuery's ajaxSetup not applying custom headers correctly for cross-domain requests? Or am I missing something in my configuration?