aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorNidboj132 <lol2s@vp.pl>2023-05-06 16:11:37 +0200
committerGitHub <noreply@github.com>2023-05-06 16:11:37 +0200
commitcbe16bdb713a5d82a7a67a4a2a4f1d49b59663ae (patch)
tree4d04c0cdea26e0e497134b99c0e34a7d9d478f34 /main.go
parentlogin test (diff)
parentfix: allow credentials cors (diff)
downloadlphub-cbe16bdb713a5d82a7a67a4a2a4f1d49b59663ae.tar.gz
lphub-cbe16bdb713a5d82a7a67a4a2a4f1d49b59663ae.tar.bz2
lphub-cbe16bdb713a5d82a7a67a4a2a4f1d49b59663ae.zip
Merge branch 'pektezol:main' into main
Diffstat (limited to 'main.go')
-rw-r--r--main.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/main.go b/main.go
index 991f3c0..ec26280 100644
--- a/main.go
+++ b/main.go
@@ -5,6 +5,7 @@ import (
5 "log" 5 "log"
6 "os" 6 "os"
7 7
8 "github.com/gin-gonic/contrib/cors"
8 "github.com/gin-gonic/gin" 9 "github.com/gin-gonic/gin"
9 "github.com/joho/godotenv" 10 "github.com/joho/godotenv"
10 "github.com/pektezol/leastportals/backend/database" 11 "github.com/pektezol/leastportals/backend/database"
@@ -19,8 +20,8 @@ import (
19// @license.name GNU General Public License, Version 2 20// @license.name GNU General Public License, Version 2
20// @license.url https://www.gnu.org/licenses/old-licenses/gpl-2.0.html 21// @license.url https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 22
22// @host lp.ardapektezol.com/api 23// @host lp.ardapektezol.com/api
23// @BasePath /v1 24// @BasePath /v1
24func main() { 25func main() {
25 if os.Getenv("ENV") == "PROD" { 26 if os.Getenv("ENV") == "PROD" {
26 gin.SetMode(gin.ReleaseMode) 27 gin.SetMode(gin.ReleaseMode)
@@ -30,6 +31,10 @@ func main() {
30 log.Fatal("Error loading .env file") 31 log.Fatal("Error loading .env file")
31 } 32 }
32 router := gin.Default() 33 router := gin.Default()
34 config := cors.DefaultConfig()
35 config.AllowAllOrigins = true
36 config.AllowCredentials = true
37 router.Use(cors.New(config))
33 database.ConnectDB() 38 database.ConnectDB()
34 // For frontend static serving - only for local debug 39 // For frontend static serving - only for local debug
35 // router.Use(static.Serve("/", static.LocalFile("./frontend/build", true))) 40 // router.Use(static.Serve("/", static.LocalFile("./frontend/build", true)))