原因: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。