随身笔记
随身笔记

跨域带cookies

前端设置:

axios({
      withCredentials: true, // ++ 新增
      method: "get",
      url: "http://localhost:8003/anotherService",
    }).then((res) => {
      console.log(res);
    });

 

后端设置:

app.all("*", (req, res, next) => {
  res.header("Access-Control-Allow-Origin", "http://localhost:8000");
  res.header("Access-Control-Allow-Credentials", "true"); // ++ 新增
  next();
});

 

https://juejin.cn/post/7066420545327218725

随身笔记

跨域带cookies
前端设置: axios({ withCredentials: true, // ++ 新增 method: "get", url: "http://localhost:8003/anotherService", }).then((res) => { conso…
扫描二维码继续阅读
2022-03-31