VUE在请求接口是跨域,调用http://localhost:8080/而不是自己的实际接口,怎么办?
Access to XMLHttpRequest at ‘https://www.wanandroid.com/banner/json’ from origin ‘http://localhost:8080’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requ
·
Access to XMLHttpRequest at ‘https://www.wanandroid.com/banner/json’ from origin ‘http://localhost:8080’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
proxy: {
‘/api’: {
target: ‘https://www.wanandroid.com’, //对应自己的接口
changeOrigin: true,
ws: true,
pathRewrite: {
‘^/api’: ‘’
}
}
}
我这么代理的,倒是不报跨域问题了,它还是localhost:8080请求的接口
这种办法试了,也没管用,有大神知道的吗,我调的玩Android的api,欢迎给我留言
更多推荐
已为社区贡献1条内容
所有评论(0)