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");//这个地址根据实际情况改动
原文地址:https://www.cnblogs.com/92xcd/p/14036529.html