修复了跨域问题
This commit is contained in:
parent
59dd6c1e70
commit
e1ce9182ab
@ -1,13 +1,6 @@
|
|||||||
import request from "@/utils/request.js";
|
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) => {
|
export const addRoleInterface = (username, password) => {
|
||||||
return request.get('/login/add', {
|
return request.get('/login/add', {
|
||||||
params: {
|
params: {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import axios from "axios";
|
|||||||
import {ElMessage} from 'element-plus'
|
import {ElMessage} from 'element-plus'
|
||||||
|
|
||||||
const instance = axios.create({
|
const instance = axios.create({
|
||||||
baseURL: 'http://localhost:8080',
|
baseURL: '/api',
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
// headers: {'X-Custom-Header': 'foobar'}
|
// headers: {'X-Custom-Header': 'foobar'}
|
||||||
});
|
});
|
||||||
@ -13,7 +13,6 @@ instance.interceptors.request.use(function (config) {
|
|||||||
return config;
|
return config;
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
// 对请求错误做些什么
|
// 对请求错误做些什么
|
||||||
console.log(error)
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -28,6 +27,7 @@ instance.interceptors.response.use(function (response) {
|
|||||||
return response;
|
return response;
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
// 对响应错误做点什么
|
// 对响应错误做点什么
|
||||||
|
ElMessage.error(error.message)
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -13,4 +13,18 @@ export default defineConfig({
|
|||||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
server: {
|
||||||
|
proxy: {
|
||||||
|
// 在此处编写代理规则
|
||||||
|
'/api': {
|
||||||
|
target: 'http://localhost:8080',
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: (path) => {
|
||||||
|
return path.replace(/\/api/, '')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user