import instance from 'dvcp-ui/lib/js/request'
import {Message} from 'element-ui'

let baseURLs = {
  production: "/",
  development: '/lan',
  oms: '/oms'
}
instance.defaults.baseURL = baseURLs[process.env.NODE_ENV]
instance.interceptors.request.eject(0);
instance.interceptors.request.use(config => {
  if (!config.withoutToken && localStorage.getItem("ui-token")) {
    config.headers['Authorization'] = ["Bearer", localStorage.getItem("ui-token")].join(" ")
  }
  return config
}, error => Message.error(error))
export default instance
