I am using the beego framework as my API and AngularJS framework on the client. I configured all CORS settings correctly. I can make a GET request. But, when I try to execute POST, beego treat is an OPTIONS request. He also throws a warning: multiple response.WriteHeader calls. what could be wrong?
My CORS setup for beego:
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,
}))
}
My request is ANGularJS
var transaction = $http.post(BASE_URL + "transaction", transactionData);
return $q.all([transaction]).then(function(response) {
console.log(response);
});
my system: Ubuntu 14.04 beego: 1.4.2 bee: 1.2.4 angularJS: 1.3.12
source
share