我用vue-cli3.X初始化一个项目,使用axios请求其它网站的API的时候出现这个怎么处理
Access to XMLHttpRequest at 'http://apisite/api/api.php' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
网上说在vue根目录配置一下proxy就可以了,但是我配置了还是不行,求大神指点
//根目录下 vue.config.js
module.exports = {
devServer:{
proxy : {
'/api':{
target:'http://apisite.api/index.php',
changeOrigin: true,
ws: true,
pathRewrite:{
'^/api': ''
}
}
}
}
}