'Access-Control-Allow-Credentials' header 在响应中是 '' 当请求的凭据模式是 'include' 时,它必须是 'true'

'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'

我正在尝试访问一些 api,代码如下:

<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
    "width=device-width, initial-scale=1.0">
  
    <title>JavaScript | fetch() Method</title>
</head>
  
<body>
    <script>

    let headers = new Headers();
    headers.append('Content-Type', 'application/json');
    headers.append('Accept', 'application/json');
    headers.append('Origin','http://localhost:3000');
        // API for get requests
    let fetchRes = fetch(
    "https://jsonplaceholder.typicode.com/todos/1", {mode: 'cors',
    credentials: 'include',
    headers: headers});

    // fetchRes is the promise to resolve
    // it by using.then() method
    fetchRes.then(res =>
        res.json()).then(d => {
            console.log(d)
        })
    </script>
</body>
  
</html>

这很好用。 但是,当我用这个 https://flask-heroku1p.herokuapp.com/add/3,5 (we created this api in https://medium.com/analytics-vidhya/flask-restful-api-with-heroku-da1ecf3e04b 替换上一个 api url 时) 它给了我这个错误:

您不需要凭据即可访问 heroku 站点。删除行 credentials: 'include', 或设置 credentials: 'omit', 将解决您的问题。