同様のことがすでにstackoverflowで議論されているようですが、まったく同じものを見つけることができませんでした。
CORS(Cross-Origin Resource Sharing)でCookieを送信しようとしていますが、うまくいきません。
これは私のコードです。
$.ajax(
{
type: "POST",
url: "http://example.com/api/getlist.json",
dataType: 'json',
xhrFields: {
withCredentials: true
},
crossDomain: true,
beforeSend: function(xhr) {
xhr.setRequestHeader("Cookie", "session=xxxyyyzzz");
},
success: function(){
alert('success');
},
error: function (xhr) {
alert(xhr.responseText);
}
}
);
リクエスト HEADER にこの Cookie が表示されません。