diff --git a/src/api/login.js b/src/api/login.js index 7fec722..0d647ea 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -1,13 +1,6 @@ import request from "@/utils/request.js"; -export const gameLoginInterface = (username, password) => { - return request.post('/api/login/login', { - username: username, - password: password, - }) -} - export const addRoleInterface = (username, password) => { return request.get('/login/add', { params: { diff --git a/src/utils/request.js b/src/utils/request.js index b34959a..fd0e387 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -2,7 +2,7 @@ import axios from "axios"; import {ElMessage} from 'element-plus' const instance = axios.create({ - baseURL: 'http://localhost:8080', + baseURL: '/api', timeout: 10000, // headers: {'X-Custom-Header': 'foobar'} }); @@ -13,7 +13,6 @@ instance.interceptors.request.use(function (config) { return config; }, function (error) { // 对请求错误做些什么 - console.log(error) return Promise.reject(error); }); @@ -28,6 +27,7 @@ instance.interceptors.response.use(function (response) { return response; }, function (error) { // 对响应错误做点什么 + ElMessage.error(error.message) return Promise.reject(error); }); diff --git a/vite.config.js b/vite.config.js index 08b288a..85aae94 100644 --- a/vite.config.js +++ b/vite.config.js @@ -13,4 +13,18 @@ export default defineConfig({ '@': fileURLToPath(new URL('./src', import.meta.url)) } }, + server: { + proxy: { + // 在此处编写代理规则 + '/api': { + target: 'http://localhost:8080', + changeOrigin: true, + rewrite: (path) => { + return path.replace(/\/api/, '') + } + } + } + } + + })