I recently ran into with posting Javascript requests to another domain. By default XHR posting to other domains is not allowed.
Following the instructions from htt
It took Microsoft years to identify the gaps and ship an out-of-band CORS module to solve this problem.
as below
In general, it is much easier than your custom headers and also offers better handling of preflight requests.
In case you need the same for IIS Express, use some PowerShell scripts I wrote.