我向Firebase上的云函数发出POST请求。当我试图提出请求时,我会收到一个CORS策略错误。好的,我设置模式:"无cors"并获得Failed to load resource: the server responded with a status of 500 ()
。
这是代码
let myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "application/json");
let raw = JSON.stringify({
"description": "Test item",
"email": "testemail@gmail.com"
});
let requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
mode: 'no-cors',
redirect: 'follow',
};
fetch("https://someURl.cloudfunctions.net/someRequest", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
代码是从Postman 复制的
有什么想法吗?
正如jaba所证实的,问题发生在服务器端。此外,这里也有同样的记录。