Enha: cookies for local dev

This commit is contained in:
Grail Finder
2025-05-09 08:01:25 +03:00
parent 8baf03595e
commit 659c8dbbec
2 changed files with 9 additions and 5 deletions

View File

@ -28,8 +28,10 @@ func LoadConfigOrDefault(fn string) *Config {
if err != nil { if err != nil {
slog.Warn("failed to read config from file, loading default", "error", err) slog.Warn("failed to read config from file, loading default", "error", err)
config.BaseURL = "https://localhost:3000" config.BaseURL = "https://localhost:3000"
config.SessionLifetime = 300 config.SessionLifetime = 30000
config.CookieSecret = "test" config.CookieSecret = "test"
config.ServerConfig.Host = "localhost"
config.ServerConfig.Port = "3000"
} }
return config return config
} }

View File

@ -107,7 +107,7 @@ func makeCookie(username string, remote string) (*http.Cookie, error) {
cookie := &http.Cookie{ cookie := &http.Cookie{
Name: cookieName, Name: cookieName,
Value: cookieValue, Value: cookieValue,
Secure: true, // Secure: true,
HttpOnly: true, HttpOnly: true,
SameSite: http.SameSiteNoneMode, SameSite: http.SameSiteNoneMode,
Domain: cfg.ServerConfig.Host, Domain: cfg.ServerConfig.Host,
@ -115,7 +115,9 @@ func makeCookie(username string, remote string) (*http.Cookie, error) {
log.Info("check remote addr for cookie set", log.Info("check remote addr for cookie set",
"remote", remote, "session", session) "remote", remote, "session", session)
if strings.Contains(remote, "192.168.0") { if strings.Contains(remote, "192.168.0") {
cookie.Domain = "home.host" // cookie.Domain = "192.168.0.101"
cookie.Domain = ""
cookie.SameSite = http.SameSiteLaxMode
log.Info("changing cookie domain", "domain", cookie.Domain) log.Info("changing cookie domain", "domain", cookie.Domain)
} }
// set ctx? // set ctx?