Files
x_admin/server/middleware/cors.go
xiangheng 8eb583397d init
2023-11-24 16:46:30 +08:00

18 lines
380 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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,
})
}