【发布时间】:2021-08-15 21:02:06
【问题描述】:
我正在使用 jquery 从 domain1 向 domain2 发送 ajax 请求。
代码如下:
let settings = {
url: "https://domain2.com",
method: "POST",
headers: {
"Access-Control-Allow-Credentials": true,
"Access-Control-Allow-Origin": "https://domain1.com",
},
contentType: "application/json",
data: JSON.stringify(data),
xhrFields: {
withCredentials: true
}
};
jQuery.ajax(settings)
.then( res => {
// Do something with result
);
但在我检查浏览器 cookie 时请求后,响应 cookie 不存在。 我还检查了 domain2 发送 cookie 的网络选项卡。
谁知道问题出在哪里?
【问题讨论】:
标签: jquery cookies cross-domain samesite