關於withCredentials與狀態碼204

The value of the ‘Access-Control-Allow-Origin’ header in the response must not be the wildcard ‘*’ when the request’s credentials mode is ‘include’. Origin ‘’ is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

http狀態碼變成產生204,前端報這個錯誤,解決方案有兩個:
1.把withCredentials設置爲false,不允許cookie
2.配置withCredentials=true, 後端需配置Access-Control-Allow-Credentials,Access-Control-Allow-Origin不能爲*, 必須是地址

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章