Files
dvcp_v2_webapp/examples/router/axios.js
2022-07-27 14:26:26 +08:00

29 lines
953 B
JavaScript

import instance from 'dvcp-ui/lib/js/request'
import {Message} from 'element-ui'
let baseURLs = {
production: "/",
development: '/lan'
}
instance.defaults.baseURL = baseURLs[process.env.NODE_ENV]
instance.interceptors.request.use(config => {
if (config.url.startsWith("/node")) {
config.baseURL = "/ns"
} else if (/\/project\/beta/.test(location.pathname)) {
config.baseURL = "/wg"
} else if (/\/project\/sass/.test(location.pathname)) {
config.baseURL = "/saas"
} else if (/\/xiushan/.test(location.pathname)) {
config.baseURL = "/xsjr"
} else if (/project\/oms/.test(location.pathname)) {
config.baseURL = "/omsapi"
} else if (/#url-/.test(location.hash)) {
config.baseURL = location.hash.replace(/#url-/, '/')
}
if (["/xsjr", "/omsapi"].includes(config.baseURL)) {
config.url = config.url.replace(/(app|auth|admin)\//, "")
}
return config
}, error => Message.error(error))
export default instance