Thursday, April 18, 2024
HomeGolangDoes not set cookies if area will not be localhost - Getting...

Does not set cookies if area will not be localhost – Getting Assist


Hey, i’ve an issue when setting the cookies apart from localhost in gin gonic

c.SetCookie("token", str, 60*60*24, "https://discussion board.golangbridge.org/", "localhost:3000", true, true) // WORKS

c.SetCookie("token", str, 60*60*24, "https://discussion board.golangbridge.org/", "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{"Settle for", "Authorization", "Content material-Sort", "Content material-Size", "X-CSRF-Token", "Token", "session", "Origin", "Host", "Connection", "Settle for-Encoding", "Settle for-Language", "X-Requested-With"},
	ExposeHeaders:    []string{"Content material-Size"},
	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 web page.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments