21 lines
549 B
Go
21 lines
549 B
Go
package middleware
|
|
|
|
import (
|
|
"EnGin/internal/global"
|
|
"time"
|
|
|
|
"github.com/gin-contrib/cors"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func CORS() gin.HandlerFunc {
|
|
return cors.New(cors.Config{
|
|
AllowOrigins: global.Config.Server.AllowOrigins,
|
|
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"},
|
|
AllowHeaders: []string{"Origin", "Content-Type", "Accept", "X-Source", "access_token", "refresh_token"},
|
|
ExposeHeaders: []string{"Content-Length"},
|
|
AllowCredentials: true,
|
|
MaxAge: 12 * time.Hour,
|
|
})
|
|
}
|