mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-16 13:10:38 +08:00
init
This commit is contained in:
17
server/middleware/cors.go
Normal file
17
server/middleware/cors.go
Normal file
@@ -0,0 +1,17 @@
|
||||
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,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user