天天看點

vue axios無法發送sessionvue axios無法發送session

vue axios無法發送session

後端在與前端互動時請求帶入session vue前端不能傳回session

後發現是vue中axiox中限制了session的傳回,需要在create中加入解開注釋

const service = axios.create({
  baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
  withCredentials: true, // send cookies when cross-domain requests
  timeout: 5000 // request timeout
})
           

後端我用的是node node需要在config.default.js中的cors中加修改origin為前端位址【不能為*】credentials:true

config.cors = {
    origin: 'http://localhost:9528',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
    credentials:true
};
           

繼續閱讀