I seem to have spent the last decade chasing this one, but still fighting it, usually on a Friday afternoon.
We have a site, on a server, let's call the server "myserver"
myserver hosts AGS so we can call stuff with "myserver/arcgis/"
The site myserver hosts has an internally set name, lets say "maps"
so users go to http:\\maps to see maps.
Most of this is now working, but one part of the code calls a Print service. So -
That is when the dreaded CORS error kicks in.
Allowed Origins is set to *
In the code I have added "esri.config.defaults.io.corsEnabledServers.push("myserver");" using the short name and fully qualified name.
I have tried adding an Allowed Origins part to every possible web.config file I can see.
But still, I get
Access to XMLHttpRequest at 'http://myserver/arcgis/rest/services/PrintService2/GPServer?f=json' from origin 'http://maps' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I am doomed to keep seeing this error until I retire.
I am losing hope of ever being able to sort it.
EDIT: Amazing, "fixed" this on a Friday afternoon - I added the port - myserver:6080 - which to me looks like the issue is in the Web Adaptor. So still a question I'd love to get answered.