diff options
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/go.mod | 1 | ||||
| -rw-r--r-- | backend/go.sum | 2 | ||||
| -rw-r--r-- | backend/handlers/login.go | 2 | ||||
| -rw-r--r-- | backend/main.go | 18 |
4 files changed, 23 insertions, 0 deletions
diff --git a/backend/go.mod b/backend/go.mod index f6eef48..ae50685 100644 --- a/backend/go.mod +++ b/backend/go.mod | |||
| @@ -8,6 +8,7 @@ require ( | |||
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | require ( | 10 | require ( |
| 11 | github.com/gin-contrib/cors v1.7.2 | ||
| 11 | github.com/golang-jwt/jwt/v4 v4.5.0 | 12 | github.com/golang-jwt/jwt/v4 v4.5.0 |
| 12 | github.com/google/uuid v1.6.0 | 13 | github.com/google/uuid v1.6.0 |
| 13 | github.com/pektezol/steam_go v1.1.2 | 14 | github.com/pektezol/steam_go v1.1.2 |
diff --git a/backend/go.sum b/backend/go.sum index 10504e4..f117b31 100644 --- a/backend/go.sum +++ b/backend/go.sum | |||
| @@ -31,6 +31,8 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2 | |||
| 31 | github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= | 31 | github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= |
| 32 | github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4= | 32 | github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4= |
| 33 | github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4= | 33 | github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4= |
| 34 | github.com/gin-contrib/cors v1.7.2 h1:oLDHxdg8W/XDoN/8zamqk/Drgt4oVZDvaV0YmvVICQw= | ||
| 35 | github.com/gin-contrib/cors v1.7.2/go.mod h1:SUJVARKgQ40dmrzgXEVxj2m7Ig1v1qIboQkPDTQ9t2E= | ||
| 34 | github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= | 36 | github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= |
| 35 | github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= | 37 | github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= |
| 36 | github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= | 38 | github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= |
diff --git a/backend/handlers/login.go b/backend/handlers/login.go index 565ebdb..408d950 100644 --- a/backend/handlers/login.go +++ b/backend/handlers/login.go | |||
| @@ -4,6 +4,7 @@ import ( | |||
| 4 | "encoding/json" | 4 | "encoding/json" |
| 5 | "fmt" | 5 | "fmt" |
| 6 | "io" | 6 | "io" |
| 7 | "log" | ||
| 7 | "net/http" | 8 | "net/http" |
| 8 | "os" | 9 | "os" |
| 9 | "time" | 10 | "time" |
| @@ -29,6 +30,7 @@ type LoginResponse struct { | |||
| 29 | // @Success 200 {object} models.Response{data=LoginResponse} | 30 | // @Success 200 {object} models.Response{data=LoginResponse} |
| 30 | // @Router /login [get] | 31 | // @Router /login [get] |
| 31 | func Login(c *gin.Context) { | 32 | func Login(c *gin.Context) { |
| 33 | log.Println(c.Request.Host) | ||
| 32 | openID := steam_go.NewOpenID(c.Request, true) | 34 | openID := steam_go.NewOpenID(c.Request, true) |
| 33 | switch openID.Mode() { | 35 | switch openID.Mode() { |
| 34 | case "": | 36 | case "": |
diff --git a/backend/main.go b/backend/main.go index 202c607..306823c 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 | ) |
| @@ -31,7 +33,23 @@ func main() { | |||
| 31 | gin.SetMode(gin.ReleaseMode) | 33 | gin.SetMode(gin.ReleaseMode) |
| 32 | } | 34 | } |
| 33 | router := gin.Default() | 35 | router := gin.Default() |
| 36 | router.Use(cors.New(cors.Config{ | ||
| 37 | AllowOrigins: []string{"*"}, | ||
| 38 | AllowMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH"}, | ||
| 39 | AllowHeaders: []string{"Origin"}, | ||
| 40 | ExposeHeaders: []string{"Content-Length"}, | ||
| 41 | AllowCredentials: true, | ||
| 42 | AllowOriginFunc: func(origin string) bool { | ||
| 43 | return origin == "https://github.com" | ||
| 44 | }, | ||
| 45 | MaxAge: 12 * time.Hour, | ||
| 46 | })) | ||
| 34 | database.ConnectDB() | 47 | database.ConnectDB() |
| 35 | api.InitRoutes(router) | 48 | api.InitRoutes(router) |
| 49 | router.Static("/static", "../frontend/build/static") | ||
| 50 | router.StaticFile("/", "../frontend/build/index.html") | ||
| 51 | router.NoRoute(func(c *gin.Context) { | ||
| 52 | c.File("../frontend/build/index.html") | ||
| 53 | }) | ||
| 36 | router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) | 54 | router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) |
| 37 | } | 55 | } |