mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-01-09 16:49:51 +08:00
20 lines
453 B
Go
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,
|
|
})
|
|
}
|