原文:axios跨域請求報錯:Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

在做項目時,用到axios,數據用post提交時,老是報錯,錯誤提示為: 如下圖: 仔細看看自己跨域配置,設置成這樣: 這是因為我在后端設置跨域請求的時候沒有所需的請求類型。於是做了如下修改: 結果就可以啦。 ...

2019-09-06 11:49 0 5562 推薦指數:

查看詳情

請求錯誤: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource

今天在學習Angular 的HttpInterceptor 攔截器時,發現添加了新的headers鍵值之后總是報錯誤。后台使用的是asp.net core。 檢查發現,在添加了新的header之后,每次請求之前都會先發送一個options請求,這個請求被后台拒絕了,所以導致報錯。我的后台 ...

Sat Jul 13 01:39:00 CST 2019 1 10123
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM