三种方法:
1、前端请求时在request对象中配置"withCredentials": true;
axios({
withCredentials: true, // ++ 新增
method: "get",
url: "http://localhost:8003/anotherService",
}).then((res) => {
console.log(res);
});
2、服务端在response的header中配置"Access-Control-Allow-Origin", "http://域名:端口号";
3、服务端在response的header中配置"Access-Control-Allow-Credentials", "true"
网友回复