CORS没有“访问控制允许来源”问题

时间:2020-07-23 13:47:00

标签: javascript heroku cors fetch

我遇到了常见的CORS Access-Control-Allow-Origin标头问题,我已经看到了很多文章。有一次,在获取请求之前添加“ https://cors-anywhere.herokuapp.com/”非常有效,但是现在我收到了一个错误。这是我的控制台告诉我的内容:

可通过“ https://cyclist-count.herokuapp.com/db.json”进行访存 (重定向自 'https://cors-anywhere.herokuapp.com/https://cyclist-count.herokuapp.com/db.json') 来源“ https://cyclist-count.herokuapp.com”已被阻止 CORS政策:在网站上没有'Access-Control-Allow-Origin'标头 请求的资源。

如果您的需求不透明,请设置 请求的模式设置为“ no-cors”,以在禁用CORS的情况下获取资源。

我发现很难确定这是否是Heroku的特定问题。谁能阐明这个问题?

这是我要提取的代码:

function dateSelected(event){
  fetch('https://cors-anywhere.herokuapp.com/https://cyclist-count.herokuapp.com/db.json', {mode: 'cors'})
    .then(response => {return response.json()}).then(data => {sumDailyRiders(data, event)})
}

如果您想签出该页面:https://cyclist-count.herokuapp.com/

谢谢!

0 个答案:

没有答案