作者 tangxvhui

跨域调整

@@ -42,5 +42,5 @@ func logLevel(s string) (i int) { @@ -42,5 +42,5 @@ func logLevel(s string) (i int) {
42 } 42 }
43 43
44 func PrintSql(bt []byte) { 44 func PrintSql(bt []byte) {
45 - logs.Debug(string(bt)) 45 + logs.Debug("SQL PRINT : ", string(bt))
46 } 46 }
@@ -94,9 +94,9 @@ func (controller *BaseController) Prepare() { @@ -94,9 +94,9 @@ func (controller *BaseController) Prepare() {
94 if controller.Ctx.Input.IsPost() || controller.Ctx.Input.IsPut() { 94 if controller.Ctx.Input.IsPost() || controller.Ctx.Input.IsPut() {
95 bodyByte := controller.Ctx.Input.RequestBody 95 bodyByte := controller.Ctx.Input.RequestBody
96 if len(bodyByte) > 1000 { 96 if len(bodyByte) > 1000 {
97 - logs.Info("====>Recv data from client: BodyData:\n ", string(bodyByte[0:1000])) 97 + logs.Info("====>Recv data from client: BodyData: ", string(bodyByte[0:1000]))
98 } else { 98 } else {
99 - logs.Info("====>Recv data from client: BodyData: \n ", string(bodyByte)) 99 + logs.Info("====>Recv data from client: BodyData: ", string(bodyByte))
100 } 100 }
101 } 101 }
102 return 102 return
@@ -13,9 +13,9 @@ func AllowCors() func(ctx *context.Context) { @@ -13,9 +13,9 @@ func AllowCors() func(ctx *context.Context) {
13 //其中Options跨域复杂请求预检 13 //其中Options跨域复杂请求预检
14 AllowMethods: []string{"*"}, 14 AllowMethods: []string{"*"},
15 //指的是允许的Header的种类 15 //指的是允许的Header的种类
16 - AllowHeaders: []string{"*"}, 16 + AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Content-Type"},
17 //公开的HTTP标头列表 17 //公开的HTTP标头列表
18 - ExposeHeaders: []string{"Content-Length"}, 18 + ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
19 //如果设置,则允许共享身份验证凭据,例如cookie 19 //如果设置,则允许共享身份验证凭据,例如cookie
20 AllowCredentials: true, 20 AllowCredentials: true,
21 }) 21 })