我正在嘗試將請求從角度前端發送到由Spring后端公開的REST控制器。REST 控制器具有注釋。@CrossOrigin我正在使用 Http 客戶端從角度應用程序發送請求。請求: const httpOptions = {
headers: new HttpHeaders({
'Authorization': 'Basic ' + basicAuthHeader,
})
}; return this.http.get(this.address + this.addressStorage.loginEndpoint + '/' + playerName, httpOptions);結果:Access to XMLHttpRequest at 'xxx' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.郵遞員發出的相同請求給出了正確的回應。我的假設:我已經使用chrome開發工具檢查了網絡選項卡:問題是否是由發送選項請求而不是 GET 請求并且 CORS 僅允許 GET 方法這一事實引起的?假設我的猜測是正確的,那么將此組件添加到彈簧啟動應用程序中會解決我的問題嗎?
添加回答
舉報
0/150
提交
取消