I am making a request where I need to pass the cookies for the current domain to another domain i.e. CORS request. Currently cookies aren't sent when making CORS requests.
The scenario:
I am on https://example.com and I make a request
syncRequest('GET', 'https://api.example.com')
This leads to a 401 unauthorised because the cookie isn't sent.
I believe the underlying request is made using XMLHttpRequest. Some documentation suggests you can include cookies when making CORS requests by setting XMLHttpRequest.withCredentials = true.
Thus, it is necessary to modify the "then-request".