I am currently having cookies set under localhost domain - I'll call it example.com
(it isn't really example.com
of course).
My api is at example.com:8888/api/myApi
When I request the above api from example.com:8080
via ajax
i.e -
I go to example.com:8080
in my chrome browser, and i have a js code which sends request to example.com:8888/api/myApi
my browser do not send any cookie. I see this from network tab in chrome dev-tools I don't see any cookie under Request Headers Section
On the other hand if I open the same URL in other tab, no other changes, All cookies are sent and I get perfect response.
I do not think it could be cross origin issue as I already getting the following core-origin related headers in response -
Access-Control-Allow-Headers: *
Access-Control-Allow-Methods: GET,POST,OPTIONS
Access-Control-Allow-Origin: *
Extra Information -
My Ajax code :
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function () {
var data;
if (httpRequest.readyState === 4) {
if (httpRequest.status === 200) {
if (httpRequest.response) {
data = httpRequest.response;
} else if (httpRequest.responseType && (httpRequest.responseType === '' || httpRequest.responseType === 'text')) {
data = httpRequest.responseText;
}
if (args.dataType && args.dataType === 'json' && typeof data === 'string') {
data = JSON.parse(data);
}
args.done(data, xdr);
} else {
args.fail(httpRequest);
}
args.always(httpRequest, data);
}
};
httpRequest.open(args.type, fullUrl);
httpRequest.setRequestHeader('Content-Type', args.contentType);
httpRequest.responseType = args.dataType;
httpRequest.send();