【问题标题】:No 'Access-Control-Allow-Origin' header is present, disable CORS but still not working不存在“Access-Control-Allow-Origin”标头,禁用 CORS 但仍无法正常工作
【发布时间】:2021-12-02 18:28:55
【问题描述】:

无论如何我可以解决这个错误吗?我试过把“”也放在请求头中,但它不起作用

对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。

axios.post("https://platform.fatsecret.com/rest/server.api?food_id=33691&method=food.get.v2&oauth_consumer_key=9a1a6fd1fff5433f9dd77daa4587bf5d&oauth_nonce=1234&oauth_signature=sAyYTJiIxOGkvFpBcH8L%2BlFQRCQ%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1245126631&oauth_version=1.0",{
            })
            .then(response=>{
                console.log(response.data);

                }
            
            )
            .catch(error=>{
                alert("wrong");
                console.log(error)
            })

【问题讨论】:

标签: javascript axios


【解决方案1】:

通常,您需要从服务器端允许它。否则会出现此错误。

【讨论】:

  • 如何从服务器端允许它?
  • 您能告诉我您使用的是哪个服务器/后端框架吗?
猜你喜欢
  • 2014-08-20
  • 2021-05-23
  • 2016-10-30
  • 1970-01-01
  • 2016-05-07
  • 2016-10-30
  • 2013-04-08
  • 2021-09-15
相关资源
最近更新 更多