File tree Expand file tree Collapse file tree 6 files changed +21
-20
lines changed Expand file tree Collapse file tree 6 files changed +21
-20
lines changed Original file line number Diff line number Diff line change 1
1
ENV = ' development'
2
2
3
3
# 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http
4
- VUE_APP_BASE_API = ' 42.194.194.178 :3000'
4
+ VUE_APP_BASE_API = ' http://localhost :3000'
5
5
# 如果接口是 http 形式, wss 需要改为 ws
6
- VUE_APP_WS_API = ' 42.194.194.178 :3000'
6
+ VUE_APP_WS_API = ' ws://localhost :3000'
7
7
8
8
# 是否启用 babel-plugin-dynamic-import-node插件
9
9
VUE_CLI_BABEL_TRANSPILE_MODULES = true
Original file line number Diff line number Diff line change 1
1
ENV = ' production'
2
2
3
3
# 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http
4
- VUE_APP_BASE_API = ' / '
4
+ VUE_APP_BASE_API = ' http://42.194.194.178:3000 '
5
5
# 如果接口是 http 形式, wss 需要改为 ws
6
- VUE_APP_WS_API = ' / '
6
+ VUE_APP_WS_API = ' ws://42.194.194.178:3000 '
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import App from './App'
3
3
import router from './router'
4
4
import store from './store'
5
5
6
- // import './router/auth'
6
+ import './router/auth'
7
7
8
8
import './assets/icon-fonts/iconfont.css'
9
9
import './assets/icon-fonts/iconfont'
Original file line number Diff line number Diff line change @@ -4,15 +4,15 @@ import { getToken } from './utils/cookie'
4
4
5
5
// 创建axios实例
6
6
const service = axois . create ( {
7
- baseURL : process . env . NODE_ENV === 'production' ? process . env . VUE_APP_BASE_API : '/' , // api 的 base_url
7
+ baseURL : process . env . VUE_APP_BASE_API , // api 的 base_url
8
8
timeout : 120000 // 请求超时时间
9
9
} )
10
10
11
11
// request拦截器设置
12
12
service . interceptors . request . use (
13
13
config => {
14
14
if ( getToken ( ) ) {
15
- config . headers [ 'Authorization' ] = getToken ( ) // 请求头设置自带 token
15
+ config . headers [ 'Authorization' ] = 'Bearer ' + getToken ( ) // 请求头设置自带 token
16
16
}
17
17
config . headers [ 'Content-Type' ] = 'application/json' // 请求的数据格式为 json
18
18
return config
@@ -26,10 +26,11 @@ service.interceptors.request.use(
26
26
// response 拦截器设置
27
27
service . interceptors . response . use (
28
28
response => {
29
- const code = response . code
30
- const message = response . msg
29
+ const data = response . data
30
+ const code = data . code
31
+ const message = data . msg
31
32
if ( code === 0 ) {
32
- return response . data
33
+ return data . data
33
34
} else {
34
35
Message ( {
35
36
type : 'error' ,
Original file line number Diff line number Diff line change @@ -14,21 +14,21 @@ module.exports = {
14
14
name : name // 配置网页title 名称
15
15
} ,
16
16
devServer : {
17
- host : 'localhost ' , // 默认是 localhost,可不配置
17
+ host : '0.0.0.0 ' , // 默认是 localhost,可不配置
18
18
port : port , // 配置端口号
19
19
open : true , // 启动是否打开浏览器
20
20
overlay : { // 是否在浏览器上显示编译的 errors 或 warnings
21
21
warnings : false ,
22
22
errors : true
23
+ } ,
24
+ proxy : {
25
+ '/' : { // 被代理的接口名
26
+ target : process . env . VUE_APP_BASE_API , // url地址
27
+ changeOrigin : true , // 发送请求头中 host 是否设置成 target
28
+ pathRewrite : { // 重定向
29
+ '^/' : ''
30
+ }
31
+ }
23
32
}
24
- // proxy: {
25
- // '/': { // 被代理的接口名
26
- // target: process.env.VUE_APP_BASE_API, // url地址
27
- // changeOrigin: true, // 发送请求头中 host 是否设置成 target
28
- // pathRewrite: { // 重定向
29
- // '^/': ''
30
- // }
31
- // }
32
- // }
33
33
}
34
34
}
You can’t perform that action at this time.
0 commit comments