use cors.Default() for cors

This commit is contained in:
nikk gitanes
2023-02-21 19:19:24 +03:00
parent 62a7b10f59
commit 269aff7079

View File

@@ -48,12 +48,13 @@ func Start(port string) {
// corsCfg.AllowHeaders = []string{"*"} // corsCfg.AllowHeaders = []string{"*"}
// corsCfg.AllowMethods = []string{"*"} // corsCfg.AllowMethods = []string{"*"}
// corsCfg.AllowPrivateNetwork = true // corsCfg.AllowPrivateNetwork = true
corsCfg := cors.DefaultConfig() // corsCfg := cors.DefaultConfig()
corsCfg.AllowAllOrigins = true // corsCfg.AllowAllOrigins = true
corsCfg.AllowHeaders = []string{"Origin", "Content-Length", "Content-Type", "X-Requested-With", "Accept", "Authorization"} // corsCfg.AllowHeaders = []string{"Origin", "Content-Length", "Content-Type", "X-Requested-With", "Accept", "Authorization"}
route := gin.New() route := gin.New()
route.Use(log.WebLogger(), blocker.Blocker(), gin.Recovery(), cors.New(corsCfg), location.Default()) // cors.Default() allows all origins - https://github.com/gin-contrib/cors#default-allows-all-origins
route.Use(log.WebLogger(), blocker.Blocker(), gin.Recovery(), cors.Default(), location.Default())
route.GET("/echo", echo) route.GET("/echo", echo)