123456789101112131415161718192021 |
- package middleware
- import (
- "time"
- "github.com/gin-contrib/cors"
- "github.com/gin-gonic/gin"
- )
- func CORS() gin.HandlerFunc {
- config := cors.Config{
- AllowAllOrigins: true,
- AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"},
- AllowHeaders: []string{"*"},
- ExposeHeaders: []string{"*"},
- AllowCredentials: false,
- MaxAge: 12 * time.Hour,
- }
- return cors.New(config)
- }
|