vue-element-admin 新版本如何解决跨域问题?

pkwftd7m  于 22天前  发布在  其他
关注(0)|答案(3)|浏览(15)

首先,强调一下,我是一名小白,才开始学习前端技术。官网介绍的跨域解决方法,完全不知道在说什么。于是百度了一下,但得出来的结果都是前年去年的,说是在什么“config/index.js”、“webpack.dev.config.js”里面设置,但我看新版本的vue-element-admin,根本找不到这些文件。甚至我在整个项目目录里,搜索“proxyTable”、“proxy”都无功而返。
希望有位好心的高人,能详细指点一下,具体应该怎么操作才能解决跨域问题。先谢谢了!
另外,我还有个疑问,为什么我访问阿里云的api时(“ http://ali-stock.showapi.com”),没有提示跨域错误,能获取到数据;但我访问阿凡达的api时(“http://api.avatardata.cn/Joke/QueryJokeByTime”),却提示跨域错误?

dfddblmv

dfddblmv1#

搜索 vue-cli3 跨域

mcdcgff0

mcdcgff02#

搜索 vue-cli3 跨域
你好!我在 vue.config.js里加了下面这段
proxy: { '/getJoker':{ target:'http://api.avatardata.cn/Joke/QueryJokeByTime', changeOrigin:true, ws:true } }
然后,用
getJokersData(){ axios({ url: '/getJoker', params: { key: 'xxxxxxxxxxxxxxxxxxxxx', time: Math.round(new Date().getTime()/1000).toString(), sort: 'desc' }, method: 'get' }).then(res => console.log(res)) .catch(err => console.log(err)) }
访问阿凡达的api,但是获取不到,提示是“data:File not found”。请问我是哪里做得不对?

olqngx59

olqngx593#

Access to XMLHttpRequest at ' http://139.196.232.39:9000/login.jsp ' (redirected from ' http://localhost:9528/data/table_list?page=0&size=10&searchText= ') from origin ' http://localhost:9528 ' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
您好请问您一下,项目以上的错误,是不是我代理出现了问题呢,页面如果间隔一段时间不操作,刷新页面就会一直报错,请问时代理出现而导致的问题吗,烦请给点提示呢。 谢谢!

相关问题