Axios调用会产生“受CORS政策阻止”错误

我正在使用牛津词典API来验证用户输入的单词。我正完全遵循the docs

const endpoint = 'lemmas'
const languagecode = 'en'
const wordId = 'example'
const url = 'https://od-api.oxforddictionaries.com/api/v2/' + endpoint + '/' + languagecode + '/' + wordId
const params = {
  app_id: 'xxxxxxxx',app_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
}
this.axios.get(url,params).then(res => {
  console.log(res)
})

但是我收到此错误消息:

  

在以下位置访问XMLHttpRequest   来自的“ https://od-api.oxforddictionaries.com/api/v2/lemmas/en/example”   原产地“ http://localhost:8080”已被CORS政策禁止:否   请求中存在“ access-control-allow-origin”标头   资源。

编辑:令人惊讶的是,即使将NPM package Oxford Dictionaries与他们在NPM页面上提供的代码段一起使用,我仍然遇到相同的CORS政策问题。

EDIT(2):刚刚尝试过another similar NPM package,结果相同。

为什么以及如何解决此问题?

gwt3344 回答:Axios调用会产生“受CORS政策阻止”错误

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3149083.html

大家都在问