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");
})