我在客户端使用 beego 框架作为我的 API 框架和 AngularJS。我已正确设置所有 CORS 设置。我可以做 GET 请求。但是,当我尝试发布时,beego 将其视为 OPTIONS 请求。它还会发出警告:multiple response.WriteHeader calls. 可能有什么问题?我的 beego CORS 设置: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); });我的系统:Ubuntu 14.04 beego:1.4.2 bee:1.2.4 angularJS:1.3.12
2 回答
鸿蒙传说
TA贡献1865条经验 获得超7个赞
这可能是因为当前有待合并到 master 中的问题/拉取请求:问题 912
没有这条线一切都很好:: router.go#L861
这似乎与commit 3bb4d6f 一致,其中显示:
// Write status code if it has been set manually // Set it to 0 afterwards to prevent "multiple response.WriteHeader calls"
(并router.go设置状态,因此出现错误消息)
Commit f962457应该可以解决这个问题,但尚未合并。
另一个问题 904提到无法检索先前在会话引擎中注册的会话数据。也许Session.on 标志可以提供帮助。
- 2 回答
- 0 关注
- 271 浏览
添加回答
举报
0/150
提交
取消
