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"}
|
2023-06-17 07:30:14 +00:00
|
|
|
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)
|
|
|
|
}
|