Files
new-api/middleware/cors.go

16 lines
355 B
Go
Raw Normal View History

2023-04-22 20:39:27 +08:00
package middleware
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
func CORS() gin.HandlerFunc {
config := cors.DefaultConfig()
2023-04-26 14:26:19 +08:00
config.AllowAllOrigins = true
2023-04-26 15:27:33 +08:00
config.AllowCredentials = true
config.AllowMethods = []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}
2023-06-20 22:04:01 +08:00
config.AllowHeaders = []string{"*"}
2023-04-22 20:39:27 +08:00
return cors.New(config)
}