我有一个简单的React客户端与axios在本地主机上,在另一边我有python fastapi在服务器端(两个https).服务器端设置一个无httponly cookie,客户端接收它,但不会设置它.这里是我的回应:
access-control-allow-credentials
true
access-control-allow-origin
https://localhost
access-control-expose-headers
set-cookie
content-length
52
content-type
application/json
date
Sun, 19 Sep 2021 12:46:09 GMT
server
uvicorn
set-cookie
fakesession=fake-cookie-session-value; Max-Age=100000000; Path=/; SameSite=none; Secure
vary
Origin
下面是我客户端代码:
export const AxTest = axios.create({
//baseURL: "https://localhost:6069",
baseURL: "https://***.***.***.***:3002",
headers: {
"Content-type": "application/json"
},
withCredentials: true,
});
cookie是没有设置,我没有收到任何错误和响应代码是200. document.cookie是空的.顺便说一句,我已经尝试了两个在我的本地主机(python和react运行在本地主机)它是设置cookie成功.
1条答案
按热度按时间xe55xuns1#
我解决了