cors.go 355 B

123456789101112131415
  1. package middleware
  2. import (
  3. "github.com/gin-contrib/cors"
  4. "github.com/gin-gonic/gin"
  5. )
  6. func CORS() gin.HandlerFunc {
  7. config := cors.DefaultConfig()
  8. config.AllowAllOrigins = true
  9. config.AllowCredentials = true
  10. config.AllowMethods = []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}
  11. config.AllowHeaders = []string{"*"}
  12. return cors.New(config)
  13. }