File tree Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Original file line number Diff line number Diff line change @@ -18,24 +18,14 @@ Vue.use(ViewUI)
18
18
console . log ( 'env' , process . env . NODE_ENV , process . env . BASE_API )
19
19
20
20
//根据环境匹配api地址
21
- // axios.defaults.baseURL = process.env.BASE_API
22
- let protocol = window . location . protocol ; //协议
23
- let host = window . location . host ; //主机
24
- let reg = / ^ l o c a l h o s t + / ;
25
- if ( reg . test ( host ) ) {
26
- //若本地项目调试使用
27
- axios . defaults . baseURL = 'http://127.0.0.1:8000' ;
28
- } else {
29
- //动态请求地址 协议 主机
30
- axios . defaults . baseURL = protocol + "//" + host + ":80" ;
21
+ if ( process . env . NODE_ENV === 'development' ) {
22
+ axios . defaults . baseURL = 'http://127.0.0.1:8000/'
23
+ } else if ( process . env . NODE_ENV === 'production' ) {
24
+ axios . defaults . baseURL = window . location . protocol + "//" + window . location . host + ":80" ;
31
25
}
32
26
//请求超时时间
33
27
axios . defaults . timeout = 10000 //超时10秒
34
28
35
- let protocol = window . location . protocol ; //协议
36
- let host = window . location . host ;
37
- axios . defaults . baseURL = protocol + "//" + host + ":80" ;
38
-
39
29
axios . interceptors . request . use ( config => {
40
30
if ( localStorage . token ) {
41
31
config . headers . Authorization = 'JWT ' + localStorage . token
You can’t perform that action at this time.
0 commit comments