ai-gateway/middleware/cors.go

16 lines
455 B
Go
Raw Normal View History

2023-04-22 12:39:27 +00:00
package middleware
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
func CORS() gin.HandlerFunc {
config := cors.DefaultConfig()
2023-04-26 06:26:19 +00:00
config.AllowAllOrigins = true
2023-04-26 07:27:33 +00:00
config.AllowCredentials = true
config.AllowMethods = []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}
config.AllowHeaders = []string{"Origin", "Content-Length", "Content-Type", "Authorization", "Accept", "Connection", "x-requested-with"}
2023-04-22 12:39:27 +00:00
return cors.New(config)
}