971be918 by renchao@pashanhoo.com

style:cas配置

1 parent c78c3b0e
/*
* @Description: 此文件主要创建 axios 实例,然后添加请求拦截器和响应拦截器
* @Autor: renchao
* @LastEditTime: 2023-06-01 16:05:00
* @LastEditTime: 2023-06-02 10:07:55
*/
import axios from 'axios'
import Cookies from 'js-cookie'
......@@ -32,6 +32,14 @@ service.interceptors.request.use(
} else {
config.headers.delete('Authorization')
}
} else {
const token = Cookies.get('token')
// 添加请求头
if (token) {
config.headers['Authorization'] = 'Bearer ' + token
} else {
config.headers.delete('Authorization')
}
}
return config
},
......