From be5313fa0092688cea04f7f1f115574765847c22 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Sat, 19 Oct 2024 16:28:00 +0300 Subject: backend: fix run ranks --- backend/main.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'backend/main.go') diff --git a/backend/main.go b/backend/main.go index a50be7e..6499b51 100644 --- a/backend/main.go +++ b/backend/main.go @@ -4,11 +4,13 @@ import ( "fmt" "log" "os" + "time" "lphub/api" "lphub/database" _ "lphub/docs" + "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" "github.com/joho/godotenv" ) @@ -34,19 +36,19 @@ func main() { database.ConnectDB() api.InitRoutes(router) // for debugging - // router.Use(cors.New(cors.Config{ - // AllowOrigins: []string{"*"}, - // AllowMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH"}, - // AllowHeaders: []string{"Origin"}, - // ExposeHeaders: []string{"Content-Length"}, - // AllowCredentials: true, - // MaxAge: 12 * time.Hour, - // })) - // router.Static("/static", "../frontend/build/static") - // router.StaticFile("/", "../frontend/build/index.html") - // router.NoRoute(func(c *gin.Context) { - // c.File("../frontend/build/index.html") - // }) + router.Use(cors.New(cors.Config{ + AllowOrigins: []string{"*"}, + AllowMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH"}, + AllowHeaders: []string{"Origin"}, + ExposeHeaders: []string{"Content-Length"}, + AllowCredentials: true, + MaxAge: 12 * time.Hour, + })) + router.Static("/static", "../frontend/build/static") + router.StaticFile("/", "../frontend/build/index.html") + router.NoRoute(func(c *gin.Context) { + c.File("../frontend/build/index.html") + }) router.MaxMultipartMemory = 200 << 20 // 200 mb limit for demos router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) } -- cgit v1.2.3