|
|
|
|
@ -33,7 +33,11 @@ axios.interceptors.request.use(config => { |
|
|
|
|
NProgress.start() // start progress bar
|
|
|
|
|
const meta = (config.meta || {}); |
|
|
|
|
const isToken = meta.isToken === false; |
|
|
|
|
if (!isURL(config.url)) config.url = baseUrl + config.url |
|
|
|
|
//地址为已经配置状态则不添加前缀
|
|
|
|
|
if (!isURL(config.url) && !config.url.startsWith(baseUrl)) { |
|
|
|
|
config.url = baseUrl + config.url |
|
|
|
|
} |
|
|
|
|
//配置请求头
|
|
|
|
|
config.headers['Authorization'] = `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`; |
|
|
|
|
if (getToken() && !isToken) { |
|
|
|
|
config.headers[website.tokenHeader] = 'bearer ' + getToken() |
|
|
|
|
@ -74,4 +78,4 @@ axios.interceptors.response.use(res => { |
|
|
|
|
return Promise.reject(new Error(error)); |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
export default axios; |
|
|
|
|
export default axios; |
|
|
|
|
|