package manage import ( "fmt" "github.com/gin-gonic/gin" ) func CORS() gin.HandlerFunc { return func(c *gin.Context) { origin := c.Request.Header.Get("Origin") c.Writer.Header().Set("Access-Control-Allow-Origin", origin) c.Writer.Header().Set("Access-Control-Max-Age", fmt.Sprintf("%d", 6000)) c.Writer.Header().Set("Access-Control-Allow-Credentials", "true") c.Writer.Header().Set( "Access-Control-Allow-Headers", "Content-Type, Cookie, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Recook-ID, X-Recook-Token, X-Requested-With, X-Recook-GYSToken,X-Recook-GysID") c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET") if c.Request.Method == "OPTIONS" { c.AbortWithStatus(200) return } c.Next() } }