package middlewares import ( "GoMembership/internal/config" "strings" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" ) func CORSMiddleware() gin.HandlerFunc { return cors.New(cors.Config{ AllowOrigins: strings.Split(config.Site.AllowOrigins, ","), AllowMethods: []string{"GET", "POST", "PATCH", "PUT", "OPTIONS"}, AllowHeaders: []string{"Origin", "Content-Type", "Accept", "Authorization", "X-Requested-With", "X-CSRF-Token"}, ExposeHeaders: []string{"Content-Length"}, AllowCredentials: true, AllowPrivateNetwork: true, MaxAge: 12 * 60 * 60, // 12 hours }) }