This commit is contained in:
xiangheng
2023-11-24 16:46:30 +08:00
commit 8eb583397d
611 changed files with 28854 additions and 0 deletions

17
server/middleware/cors.go Normal file
View 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,
})
}