diff --git a/mock/index.js b/mock/index.js index e14f94e..90e2ffe 100644 --- a/mock/index.js +++ b/mock/index.js @@ -53,9 +53,10 @@ export function mockXHR() { // for mock server const responseFake = (url, type, respond) => { return { - url: new RegExp(`/mock${url}`), + url: new RegExp(`${process.env.VUE_APP_BASE_API}${url}`), type: type || 'get', response(req, res) { + console.log('request invoke:' + req.path) res.json(Mock.mock(respond instanceof Function ? respond(req, res) : respond)) } } diff --git a/mock/table.js b/mock/table.js index a072a21..ba95f76 100644 --- a/mock/table.js +++ b/mock/table.js @@ -13,7 +13,7 @@ const data = Mock.mock({ export default [ { - url: '/table/list', + url: '/vue-admin-template/table/list', type: 'get', response: config => { const items = data.items diff --git a/mock/user.js b/mock/user.js index 43f93a0..f007cd9 100644 --- a/mock/user.js +++ b/mock/user.js @@ -26,7 +26,7 @@ const users = { export default [ // user login { - url: '/user/login', + url: '/vue-admin-template/user/login', type: 'post', response: config => { const { username } = config.body @@ -49,7 +49,7 @@ export default [ // get user info { - url: '/user/info\.*', + url: '/vue-admin-template/user/info\.*', type: 'get', response: config => { const { token } = config.query @@ -72,7 +72,7 @@ export default [ // user logout { - url: '/user/logout', + url: '/vue-admin-template/user/logout', type: 'post', response: _ => { return { diff --git a/src/api/table.js b/src/api/table.js index e29c294..2752f52 100644 --- a/src/api/table.js +++ b/src/api/table.js @@ -2,7 +2,7 @@ import request from '@/utils/request' export function getList(params) { return request({ - url: '/table/list', + url: '/vue-admin-template/table/list', method: 'get', params }) diff --git a/src/api/user.js b/src/api/user.js index de69f70..8ff4389 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -2,7 +2,7 @@ import request from '@/utils/request' export function login(data) { return request({ - url: '/user/login', + url: '/vue-admin-template/user/login', method: 'post', data }) @@ -10,7 +10,7 @@ export function login(data) { export function getInfo(token) { return request({ - url: '/user/info', + url: '/vue-admin-template/user/info', method: 'get', params: { token } }) @@ -18,7 +18,7 @@ export function getInfo(token) { export function logout() { return request({ - url: '/user/logout', + url: '/vue-admin-template/user/logout', method: 'post' }) } diff --git a/vue.config.js b/vue.config.js index 4244cfc..f52964a 100644 --- a/vue.config.js +++ b/vue.config.js @@ -36,18 +36,7 @@ module.exports = { warnings: false, errors: true }, - proxy: { - // change xxx-api/login => mock/login - // detail: https://cli.vuejs.org/config/#devserver-proxy - [process.env.VUE_APP_BASE_API]: { - target: `http://127.0.0.1:${port}/mock`, - changeOrigin: true, - pathRewrite: { - ['^' + process.env.VUE_APP_BASE_API]: '' - } - } - }, - after: require('./mock/mock-server.js') + before: require('./mock/mock-server.js') }, configureWebpack: { // provide the app's title in webpack's name field, so that