express-session获取值为undefined

项目为vue-cli4 + express 搭建

解决方式

1.前端 axios封装的时候需要设置  

  axios.defaults.withCredentials=true;// 允许携带cookie
2.后端跨域配置中添加如下代码
  res.header("Access-Control-Allow-Credentials", "true");
      res.header("Access-Control-Allow-Origin", "http://localhost:8086");//这个地址根据实际情况改动
posted @ 2020-11-25 15:44  树叶————  阅读(444)  评论(0编辑  收藏  举报