Compare commits

..

3 Commits

Author SHA1 Message Date
17cf37d4ec Merge pull request '(FIX): Dev environemnt fixes in the backend' (#69) from refactor/react into master
All checks were successful
Deploy application with Docker / build_and_deploy (push) Successful in 45s
Reviewed-on: #69
2026-01-09 10:08:40 -07:00
168ac23d39 Merge branch 'master' into refactor/react 2026-01-09 10:08:31 -07:00
Hayden Hargreaves
bb52e1bee3 (FIX): Dev environemnt fixes in the backend 2026-01-09 10:07:55 -07:00

View File

@ -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"
// 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.SetSameSite(http.SameSiteNoneMode)
ctx.SetCookie(name, value, maxAge, path, domain, secure, httpOnly) ctx.SetCookie(
name,
value,
maxAge,
path,
".gophernest.net", // or your backend domain / parent
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,
)
}
// TODO: This whole system is stupid now
// 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)
} }