mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-09-26 20:21:19 +08:00
18 lines
380 B
Go
18 lines
380 B
Go
package middleware
|
||
|
||
import (
|
||
"github.com/gin-contrib/cors"
|
||
"github.com/gin-gonic/gin"
|
||
"time"
|
||
)
|
||
|
||
//Cors CORS(跨域资源共享)中间件
|
||
func Cors() gin.HandlerFunc {
|
||
return cors.New(cors.Config{
|
||
AllowOrigins: []string{"*"},
|
||
AllowHeaders: []string{"*"},
|
||
AllowMethods: []string{"OPTIONS", "GET", "POST", "POST", "DELETE", "PUT"},
|
||
MaxAge: 1 * time.Hour,
|
||
})
|
||
}
|