loulijun2021
2022-06-19 6c11bdd4bba46b9bc5f298181b58ae96bc47073d
src/utils/request.js
@@ -3,12 +3,13 @@
import store from '@/store'
import { getCookie, getToken } from '@/utils/auth'
// create an axios instance
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
})
// axios.defaults.withCredentials = true
// request interceptor
service.interceptors.request.use(
@@ -21,11 +22,10 @@
    // please modify it according to the actual situation
    // config.headers['X-Token'] = getToken()
    //   config.headers['Authorization'] = 'admin=' + getCookie('admin') + ';navTabId=' + getCookie('navTabId')
      config.headers['Cookie'] = 'admin=' + getCookie('admin') + ';navTabId=' + getCookie('navTabId')
    //   config.headers['Cookie'] = 'admin=' + getCookie('admin') + ';navTabId=' + getCookie('navTabId')
    //   document.cookie = 'admin=' + getCookie('admin') + ';navTabId=' + getCookie('navTabId')
    //   document.cookie = 'admin'
    }
    console.log(config, 1)
    return config
  },
  error => {
@@ -55,7 +55,7 @@
      Message({
        message: res.Message || 'Error',
        type: 'error',
        duration: 5 * 1000
        duration: 10 * 1000
      })
      // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
@@ -81,7 +81,7 @@
    Message({
      message: error.message,
      type: 'error',
      duration: 5 * 1000
      duration: 10 * 1000
    })
    return Promise.reject(error)
  }