I have a site at primary.example.com
that serves a page which includes a javascript file from other.example.com
That javascript makes an XHR/ajax GET
request to other.example.com/data.json
I think this is a CORS request because the origin should be primary.example.com
Therefore I am expecting the data.json
request to include the Origin
header. The browser should add this to the javascript request because it's going to a different domain than the page was loaded from.
All browsers I have tested on (Chrome, Firefox, WebKit) do this. But looking at my server logs I see lots of requests for data.json
which were denied by the server at other.example.com
because they did not send an Origin header in the request. Why would that be?
Edit
I don't know if this is relevant, but it's just occurred to me that it might be: the initial page load is triggered by a 302 redirect from the other server.
The full process is this:
In this diagram, request ➐ is the AJAX request that is mostly but not always sent with an Origin
header in the request.