(FIX): Dev environemnt fixes in the backend
This commit is contained in:
parent
f7ebc56856
commit
bb52e1bee3
@ -21,8 +21,6 @@ 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 {
|
||||||
@ -36,19 +34,46 @@ 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())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This whole system is stupid now
|
switch s.deps.EnvironmentConfig.Environment {
|
||||||
if s.deps.EnvironmentConfig.Environment == "prod" {
|
case "prod":
|
||||||
secure = true
|
// Cross-site between subdomains, HTTPS only
|
||||||
// domain = "potion.gophernest"
|
ctx.SetSameSite(http.SameSiteNoneMode)
|
||||||
// domain = s.deps.EnvironmentConfig.Domain
|
ctx.SetCookie(
|
||||||
domain = ".gophernest.net"
|
name,
|
||||||
|
value,
|
||||||
} else if s.deps.EnvironmentConfig.Environment == "dev" {
|
maxAge,
|
||||||
secure = false
|
path,
|
||||||
// domain = s.deps.EnvironmentConfig.Domain
|
".gophernest.net", // or your backend domain / parent
|
||||||
domain = "localhost"
|
true, // secure
|
||||||
|
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,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.SetSameSite(http.SameSiteNoneMode)
|
// TODO: This whole system is stupid now
|
||||||
ctx.SetCookie(name, value, maxAge, path, domain, secure, httpOnly)
|
// if s.deps.EnvironmentConfig.Environment == "prod" {
|
||||||
|
// 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