I have access to my "domainA" including server configuration. Actually the server configuration allow CORS only on same origin. I did not understand how exactly works, I try to explain my dubts.
I request with my browser the domainA (Access-Control-Allow-Origin: same-origin) and when I request the page it will download domainA.js that contains an AJAX call (simple GET request) to a domainB (third party site). In the browser console the request is blocked due to CORS. I don't understand who is the exact responsible for the blocked request.
Scenario 1: I can edit my server configuration domainA to allow for example any origin (Access-Control-Allow-Origin: *), domainB for example (is not mine) is set to same origin. Can I make the AJAX call from domainA to domainB?
Scenario 2: domainA with same origin and domainB with any origin. Can I make the AJAX call from domainA to domainB?
I'm little bit confused about CORS. I try to read many guide but I did not find something exhaustive: If I understand the browser send an Origin header request to domainA and the domainA send to the browser a header response with a list of domains (domainB, domainC). In this case that list tells to the browser something like "ok you are allow" to make for example AJAX call to that list (domainB, domainC). In this case to make the AJAX call (GET) from domainA to domainB or domainC is sufficient this settings (Access-Control-Allow-Origin: [domainA, domainB]) or I need also that domainB or domainC allows the domainA in their header response when they will be contact by the AJAX request of the domainA?