我正在尝试 whatwg-fetch (用于 Fetch API 的 polyfill),并且在执行 POST 时,会执行预检。但是由于在将 OPTIONS 发送到 REST 服务时未发送凭据,因此我收到了“未经授权”的响应。
return fetch('http://localhost:8080/activity', {
credentials: 'include',
method: 'POST',
mode: 'cors',
body: JSON.stringify(activity),
headers: new Headers({ 'Content-Type': 'application/json' })
});