From 279785b0686f3de1763056286a80360cdf5264f2 Mon Sep 17 00:00:00 2001 From: inleft <inleft@qq.com> Date: Thu, 10 Feb 2022 18:21:39 +0800 Subject: [PATCH] 添加api请求地址 --- src/utils/request.js | 9 ++++++--- vue.config.js | 13 +++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/utils/request.js b/src/utils/request.js index b9e2a46..2a3558b 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -20,7 +20,6 @@ const err = (error) => { if (error.response) { - const data = error.response.data // const token = Vue.ls.get(ACCESS_TOKEN) if (error.response.status === 404) { @@ -38,8 +37,12 @@ }) } if (error.response.status === 500) { - if (data.message.length > 0) { - message.error(data.message) + if (data.message == undefined) { + message.error(error.response.data) + } else { + if (data.message.length > 0) { + message.error(data.message) + } } } if (error.response.status === 401 && !(data.result && data.result.isLogin)) { diff --git a/vue.config.js b/vue.config.js index 04b875d..f8025fd 100644 --- a/vue.config.js +++ b/vue.config.js @@ -37,4 +37,17 @@ }, }, }, + devServer: { + port: 8080, + proxy: { + '/api': { + target: process.env.VUE_APP_API_BASE_URL, + ws: false, + changeOrigin: true, + pathRewrite: { + '^/api': '' // 需要rewrite的, + } + } + } + }, }; -- Gitblit v1.9.1