原因:在 CORS 标头 'Access-Control-Allow-Credentials' 中应为 'true'
原因
Reason: expected 'true' in CORS header 'Access-Control-Allow-Credentials'
哪里出错了?
CORS 请求要求服务器允许使用凭据,但服务器的 Access-Control-Allow-Credentials
头的值未设置为 true
以启用凭据的使用。
若要解决客户端上的此问题,请修改代码以不请求使用凭据。
- 如果使用 Fetch API,请确保
Request.credentials
为"omit"
。 - 如果使用
XMLHttpRequest
发出请求,请确保您未将withCredentials
设置为true
。 - 如果使用 服务器发送事件,请确保
EventSource.withCredentials
为false
(这是默认值)。
若要通过更改服务器配置来消除此错误,请调整服务器配置,将 Access-Control-Allow-Credentials
头的值设置为 true
。