Doesn't set cookies if domain is not localhost

Hello, i have a problem when setting the cookies other than localhost in gin gonic

c.SetCookie("token", str, 60*60*24, "/", "localhost:3000", true, true) // WORKS

c.SetCookie("token", str, 60*60*24, "/", "192.162.1.12:3000", true, true) // DOSNT WORK

my headers are like this

router.Use(cors.New(cors.Config{
	AllowOrigins:     []string{"http://localhost:3000", "http://192.168.1.10:3000"},
	AllowMethods:     []string{"POST", "OPTIONS", "GET", "PUT", "DELETE"},
	AllowHeaders:     []string{"Accept", "Authorization", "Content-Type", "Content-Length", "X-CSRF-Token", "Token", "session", "Origin", "Host", "Connection", "Accept-Encoding", "Accept-Language", "X-Requested-With"},
	ExposeHeaders:    []string{"Content-Length"},
	AllowCredentials: true,
	// AllowOriginFunc: func(origin string) bool {
	// 	return origin == "https://github.com"
	// },
	MaxAge: 24 * time.Hour,
}))

Im calling the api from my localhost “http://192.162.1.12:3000” react page.

Solved by adding

c.SetCookie(“token”, str, 606024, “/”, “http://localhost”, true, true)

c.SetCookie(“token”, str, 606024, “/”, “http://192.162.1.12”, true, true)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.