teldrive/pkg/middleware/cors.go
2023-12-03 01:17:23 +05:30

20 lines
453 B
Go

package middleware
import (
"time"
"github.com/divyam234/cors"
"github.com/gin-gonic/gin"
)
func Cors() gin.HandlerFunc {
return cors.New(cors.Config{
AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"},
AllowHeaders: []string{"Authorization", "Content-Length", "Content-Type"},
AllowCredentials: true,
AllowOriginFunc: func(origin string) bool {
return true
},
MaxAge: 12 * time.Hour,
})
}