diff options
Diffstat (limited to 'backend/main.go')
| -rw-r--r-- | backend/main.go | 28 |
1 files changed, 15 insertions, 13 deletions
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 ( | |||
| 4 | "fmt" | 4 | "fmt" |
| 5 | "log" | 5 | "log" |
| 6 | "os" | 6 | "os" |
| 7 | "time" | ||
| 7 | 8 | ||
| 8 | "lphub/api" | 9 | "lphub/api" |
| 9 | "lphub/database" | 10 | "lphub/database" |
| 10 | _ "lphub/docs" | 11 | _ "lphub/docs" |
| 11 | 12 | ||
| 13 | "github.com/gin-contrib/cors" | ||
| 12 | "github.com/gin-gonic/gin" | 14 | "github.com/gin-gonic/gin" |
| 13 | "github.com/joho/godotenv" | 15 | "github.com/joho/godotenv" |
| 14 | ) | 16 | ) |
| @@ -34,19 +36,19 @@ func main() { | |||
| 34 | database.ConnectDB() | 36 | database.ConnectDB() |
| 35 | api.InitRoutes(router) | 37 | api.InitRoutes(router) |
| 36 | // for debugging | 38 | // for debugging |
| 37 | // router.Use(cors.New(cors.Config{ | 39 | router.Use(cors.New(cors.Config{ |
| 38 | // AllowOrigins: []string{"*"}, | 40 | AllowOrigins: []string{"*"}, |
| 39 | // AllowMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH"}, | 41 | AllowMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH"}, |
| 40 | // AllowHeaders: []string{"Origin"}, | 42 | AllowHeaders: []string{"Origin"}, |
| 41 | // ExposeHeaders: []string{"Content-Length"}, | 43 | ExposeHeaders: []string{"Content-Length"}, |
| 42 | // AllowCredentials: true, | 44 | AllowCredentials: true, |
| 43 | // MaxAge: 12 * time.Hour, | 45 | MaxAge: 12 * time.Hour, |
| 44 | // })) | 46 | })) |
| 45 | // router.Static("/static", "../frontend/build/static") | 47 | router.Static("/static", "../frontend/build/static") |
| 46 | // router.StaticFile("/", "../frontend/build/index.html") | 48 | router.StaticFile("/", "../frontend/build/index.html") |
| 47 | // router.NoRoute(func(c *gin.Context) { | 49 | router.NoRoute(func(c *gin.Context) { |
| 48 | // c.File("../frontend/build/index.html") | 50 | c.File("../frontend/build/index.html") |
| 49 | // }) | 51 | }) |
| 50 | router.MaxMultipartMemory = 200 << 20 // 200 mb limit for demos | 52 | router.MaxMultipartMemory = 200 << 20 // 200 mb limit for demos |
| 51 | router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) | 53 | router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) |
| 52 | } | 54 | } |