Javascript 在构建web应用程序时,如何绕过客户端的cors错误?

Javascript 在构建web应用程序时,如何绕过客户端的cors错误?,javascript,api,axios,nuxt.js,Javascript,Api,Axios,Nuxt.js,我正在尝试使用axios在我的nuxt应用程序中向githubjobs API发出get请求。我已经正确设置和配置了axios。以下是我要发送的操作: async defaultJobsFetch({commit}){ try{ const res = await axios.get('https://jobs.github.com/positions.json?location=new+york') const jobs = res.data;

我正在尝试使用axios在我的nuxt应用程序中向githubjobs API发出get请求。我已经正确设置和配置了axios。以下是我要发送的操作:

  async defaultJobsFetch({commit}){
    try{
      const res = await axios.get('https://jobs.github.com/positions.json?location=new+york')
      const jobs = res.data;
      commit('getJobs', jobs)
    }catch(error){
      commit("errored");
      console.log(error)
    }
    finally{
      commit('changeLoading')
    }
  },
我也尝试过使用,但仍然出现错误403


我注意到它在我的本地机器上运行良好,但当我部署并尝试加载部署的应用程序时,我没有收到响应,而是收到403错误。该应用程序托管在heroku上,当您访问该站点时,请检查控制台以查看错误

一个解决方法是使用类似CORS unblock的chrome扩展,或者尝试在标题中包含以下内容:

访问控制允许来源:*


你可以试试,而不是

我也试过,但也没用