我在客戶端使用 beego 框架作為我的 API 框架和 AngularJS。我已正確設(shè)置所有 CORS 設(shè)置。我可以做 GET 請求。但是,當(dāng)我嘗試發(fā)布時(shí),beego 將其視為 OPTIONS 請求。它還會(huì)發(fā)出警告:multiple response.WriteHeader calls. 可能有什么問題?我的 beego CORS 設(shè)置:func init() { orm.RegisterDataBase("default", "mysql", "root:@tcp(127.0.0.1:3306)/fakeapi") beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{ AllowOrigins: []string{"*"}, AllowMethods: []string{"GET", "DELETE", "PUT", "PATCH", "POST"}, AllowHeaders: []string{"Origin"}, ExposeHeaders: []string{"Content-Length"}, AllowCredentials: true, }))}我的 AngularJS 請求var transaction = $http.post(BASE_URL + "transaction", transactionData); return $q.all([transaction]).then(function(response) { console.log(response); });我的系統(tǒng):Ubuntu 14.04 beego:1.4.2 bee:1.2.4 angularJS:1.3.12
POST 請求被視為 beego 框架上的 OPTIONS
哆啦的時(shí)光機(jī)
2021-09-13 15:31:45