package middleware import ( "jd-book-uploader/config" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" ) // SetupCORS configures CORS middleware based on application config func SetupCORS(cfg *config.Config) fiber.Handler { return cors.New(cors.Config{ AllowOrigins: cfg.FrontendURL, AllowMethods: "GET,POST,PUT,DELETE,OPTIONS", AllowHeaders: "Origin,Content-Type,Accept,Authorization", AllowCredentials: true, ExposeHeaders: "Content-Length", MaxAge: 3600, // 1 hour }) }