Compare commits
No commits in common. "17cf37d4ec62050cad8a2ba696ecad252c931328" and "32256b3c0e6d11255d93d40d3f1bcbdea55c7273" have entirely different histories.
17cf37d4ec
...
32256b3c0e
@ -21,6 +21,8 @@ func (s *Server) SetCookie(ctx *gin.Context, name, value string, duration time.D
|
|||||||
path string = "/"
|
path string = "/"
|
||||||
httpOnly bool = false // NOTE: Should use false so React can see it!
|
httpOnly bool = false // NOTE: Should use false so React can see it!
|
||||||
maxAge int
|
maxAge int
|
||||||
|
secure bool = true
|
||||||
|
domain string = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
if duration < 0 {
|
if duration < 0 {
|
||||||
@ -34,46 +36,19 @@ func (s *Server) SetCookie(ctx *gin.Context, name, value string, duration time.D
|
|||||||
maxAge = int(time.Until(time.Now().Add(duration)).Seconds())
|
maxAge = int(time.Until(time.Now().Add(duration)).Seconds())
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s.deps.EnvironmentConfig.Environment {
|
// TODO: This whole system is stupid now
|
||||||
case "prod":
|
if s.deps.EnvironmentConfig.Environment == "prod" {
|
||||||
// Cross-site between subdomains, HTTPS only
|
secure = true
|
||||||
ctx.SetSameSite(http.SameSiteNoneMode)
|
// domain = "potion.gophernest"
|
||||||
ctx.SetCookie(
|
// domain = s.deps.EnvironmentConfig.Domain
|
||||||
name,
|
domain = ".gophernest.net"
|
||||||
value,
|
|
||||||
maxAge,
|
} else if s.deps.EnvironmentConfig.Environment == "dev" {
|
||||||
path,
|
secure = false
|
||||||
".gophernest.net", // or your backend domain / parent
|
// domain = s.deps.EnvironmentConfig.Domain
|
||||||
true, // secure
|
domain = "localhost"
|
||||||
httpOnly,
|
|
||||||
)
|
|
||||||
case "dev":
|
|
||||||
// Local dev on http://localhost:PORT
|
|
||||||
ctx.SetSameSite(http.SameSiteLaxMode)
|
|
||||||
ctx.SetCookie(
|
|
||||||
name,
|
|
||||||
value,
|
|
||||||
maxAge,
|
|
||||||
path,
|
|
||||||
"", // no Domain → default to current host
|
|
||||||
false, // not secure on plain HTTP
|
|
||||||
httpOnly,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This whole system is stupid now
|
ctx.SetSameSite(http.SameSiteNoneMode)
|
||||||
// if s.deps.EnvironmentConfig.Environment == "prod" {
|
ctx.SetCookie(name, value, maxAge, path, domain, secure, httpOnly)
|
||||||
// secure = true
|
|
||||||
// // domain = "potion.gophernest"
|
|
||||||
// // domain = s.deps.EnvironmentConfig.Domain
|
|
||||||
// domain = ".gophernest.net"
|
|
||||||
//
|
|
||||||
// } else if s.deps.EnvironmentConfig.Environment == "dev" {
|
|
||||||
// secure = false
|
|
||||||
// // domain = s.deps.EnvironmentConfig.Domain
|
|
||||||
// domain = "localhost"
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ctx.SetSameSite(http.SameSiteNoneMode)
|
|
||||||
// ctx.SetCookie(name, value, maxAge, path, domain, secure, httpOnly)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user