2fas-server/internal/common/http/cors.go

19 lines
465 B
Go
Raw Normal View History

2022-12-31 10:22:38 +01:00
package http
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"time"
)
func corsMiddleware() gin.HandlerFunc {
return cors.New(cors.Config{
AllowOrigins: []string{"*"},
AllowMethods: []string{"PUT", "PATCH", "POST", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Origin", "Content-Type", "x-requested-with"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
MaxAge: 12 * time.Hour,
})
}