From 17d91caec7b6601cfd08bcaed66565db34007f3d Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 12 Jun 2023 10:31:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B7=A8=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/middlewares/cors.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/middlewares/cors.go b/api/middlewares/cors.go index 11e0839..99a3070 100644 --- a/api/middlewares/cors.go +++ b/api/middlewares/cors.go @@ -13,7 +13,7 @@ func Cors() gin.HandlerFunc { method := c.Request.Method origin := c.Request.Header.Get("Origin") if origin != "" { - c.Header("Access-Control-Allow-Origin", origin) + c.Header("Access-Control-Allow-Origin", "*") c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE") c.Header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization") c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Cache-Control, Content-Language, Content-Type") @@ -22,6 +22,7 @@ func Cors() gin.HandlerFunc { } if method == "OPTIONS" { c.AbortWithStatus(http.StatusNoContent) + return } c.Next() }