update cors to allow gogame-frontend requests

This commit is contained in:
arnaucube
2019-06-15 13:56:27 +02:00
parent 80fe8883b1
commit 513836c4c7
3 changed files with 12 additions and 4 deletions

View File

@@ -3,3 +3,5 @@
Nostalgic OGame clone in Go
WIP
The frontend is in https://github.com/arnaucube/gogame-frontend

View File

@@ -27,9 +27,9 @@ func handleInfo(c *gin.Context) {
}
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) {

View File

@@ -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{