故:在CORS头Access-Control-Allow-Credentials中预期为true
理由
故:在CORS头Access-Control-Allow-Credentials中预期设为true
错在了哪儿?
CORS请求要求服务器允许使用凭据,但是服务器的HTTPHeader:Access-Control-Allow-Credentials标头的值并没有设置为true 。
想要在客户端解决此问题,请修改代码以不请求使用凭据:
- 如果要使用
XMLHttpRequest
发出请求,请确保没有将XMLHttpRequest.withCredentials”,“ withCredentials
}设置为true。 - 如果使用 Server-sent events,请确保
EventSource.withCredentials
为false(default)。 - 如果使用 Fetch API,请确保
Request.credentials
为“omit”。
想要通过更改服务器的配置来消除此错误,请调整服务器的配置以将Access-Control-Allow-Credentials标头的值设置为true。
更多
- CORS errors
- Glossary: CORS
- CORS introduction