Access to XMLHttpRequest at 'http://192.168.31.108:8080/meeting/select?meetingId=11' from origin 'http://localhost:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
cors跨域问题,前端可以很简单解决,在config文件里面
server: {
proxy: {
'/api': {
target: 'http://192.168.31.108:8080',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
}
}
},加上一个代理,并且把原来的地址
http://192.168.31.108:8080/meeting/select?meetingId=11改为
http://api/meeting/select?meetingId=11
例如
axios({
url: "http:/api/meeting/select",
method: 'get',
params: { meetingId: 11 }
}).then(res => {
console.log(res.data.data);
}).catch(error => {
console.error(error);
});