Explorar el Código

请求携带token

zhongxiaoyu hace 2 años
padre
commit
ad8ac1b99c
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      src/utils/request.js

+ 2 - 1
src/utils/request.js

@@ -1,7 +1,7 @@
 import axios from 'axios'
 import { MessageBox, Message } from 'element-ui'
 import store from '@/store'
-// import { getToken } from '@/utils/auth'
+import { getToken } from '@/utils/auth'
 // create an axios instance
 // let baseURL
 // if (process.env.NODE_ENV === "development") {
@@ -27,6 +27,7 @@ service.interceptors.request.use(
       // ['X-Token'] is a custom headers key
       // please modify it according to the actual situation
       // config.headers['X-Token'] = getToken()
+      config.headers['token'] = getToken()
     }
     return config
   },