arnaucube
arnaucube/gogame-oldPublic Self-hosted repository
update cors to allow gogame-frontend requests
arnaucube arnaucube@gmail.com
Sat, 15 Jun 2019 13:56:27 +0200
commit

513836c4c7d1460c10cedb6c7db8337f2414db23

parent

80fe8883b165dd52a0b1fcf229a23f59ce62fa23

3 files changed, 12 insertions(+), 4 deletions(-)

jump to
M README.md → README.md

@@ -3,3 +3,5 @@

Nostalgic OGame clone in Go WIP + +The frontend is in https://github.com/arnaucube/gogame-frontend
M endpoint/handlers.go → endpoint/handlers.go

@@ -27,9 +27,9 @@ })

} type RegisterMsg struct { - Name string `binding:"required"` - Password string `binding:"required"` - Email string `binding:"required"` + Name string `json:"name" binding:"required"` + Password string `json:"password" binding:"required"` + Email string `json:"email" binding:"required"` } func handleRegister(c *gin.Context) {
M endpoint/serve.go → endpoint/serve.go

@@ -23,7 +23,13 @@ var gameservice *gamesrv.Service

func newApiService() *gin.Engine { api := gin.Default() - api.Use(cors.Default()) + api.Use(cors.New(cors.Config{ + AllowOrigins: []string{"http://127.0.0.1:8080"}, + AllowMethods: []string{"GET", "POST"}, + AllowHeaders: []string{"Authorization", "Content-Type"}, + AllowCredentials: true, + MaxAge: 12 * time.Hour, + })) // the jwt middleware authMiddleware, err := jwt.New(&jwt.GinJWTMiddleware{