nodejs跨域设置cookie失败,用的core中间件,前端vue用的axios

nodejs怎么才能跨域设置cookie呀,我搜的用cors中间件,设置了之后也不行,不知道是哪里写错了,求大哥们指点一下,谢谢。
这个是cors设置的

app.use(cors({
 "origin": ["localhost:8080"],  //允许所有前端域名
  "credentials":true,//允许携带凭证
  "methods": "GET,HEAD,PUT,PATCH,POST,DELETE", //被允许的提交方式
  "allowedHeaders":['Content-Type','Authorization']//被允许的post方式的请求头
})); 

这个是前端设置的,前端用了代理

axios({
    url:"/api/login/loginIn",
    params:{tel:this.username,password:this.password},
    withCredentials: true
}).then(res=>{
    this.$store.state.bool = true;
    this.$router.push("/user");
})
阅读 1.1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题