teldrive/pkg/middleware/cors.go

21 lines
453 B
Go
Raw Normal View History

2023-12-03 03:47:23 +08:00
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,
})
}